Results 1 to 4 of 4
  1. #1
    Ara1992 is offline Member
    Join Date
    Dec 2009
    Posts
    8
    Rep Power
    0

    Default Help verifyin duplicate entrier

    Hi,

    I have a text file that has around 8 000 lines.

    My program loops through each lines and inserts teh appropirate value in an array. But I need to make sure that there is no duplicate value.

    So far I have this:

    Java Code:
    for (int i = 0; intervalleDiagramme[i] != valeur; i++)
                        {
                             for (int x = 0; x < i; x++) {
                                 if(intervalleDiagramme[i] != intervalleDiagramme[x])
                                 {
                                    intervalleDiagramme[j] = valeur;
                                 }
                            System.out.println(intervalleDiagramme[j] + " " + intervalleDiagramme[x]);
                             }
                        }
    But as you might of guessed, it doesnt' work...

    Can someone help me please?

    Thanks,
    ara

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  3. #3
    Ara1992 is offline Member
    Join Date
    Dec 2009
    Posts
    8
    Rep Power
    0

    Default

    Hi,

    Thanks for your reply,

    The thing is I dont know whats a set.

    And also, this is a school project. And we can't use something we didn't learn in class....

    It's just this part... the worst thing is I already did it in the past... but I just cant seem to do it again... and the due date is tommorow. So it adds an extra stress

  4. #4
    Ara1992 is offline Member
    Join Date
    Dec 2009
    Posts
    8
    Rep Power
    0

    Default

    Hi,

    So I figured out my problem and I changed my code.

    But it takes forever to check...

    Here is the loop:

    Java Code:
    while ((ligne = lecteurFichier.readLine()) != null) {
                if (z > 3)
                {
                    String valeur = "";
                    String dist = "";
                    boolean unique = true;
                    String [] chiffre = ligne.split(";");
                     if (intervalleAnalyser == 1)
                    {
                        valeur = chiffre[3];
                        dist = chiffre[4];
                    }
                    if (intervalleAnalyser == 2)
                    {
                        valeur = chiffre[2];
                        dist = chiffre[4];
                    }
                    if (intervalleAnalyser == 3)
                    {
                        valeur = chiffre[1];
                        dist = chiffre[4];
                    }
                    if (z == 4) {
                        intervalleDiagramme[j] = valeur;
                        j++;
                    }
                    if (z > 4) {
    
                        for (int i = 0; i < intervalleDiagramme.length; i++)
                        {
                             for (int x = 0; x < i; x++)
                             {
                                 if(intervalleDiagramme[i] == intervalleDiagramme[x])
                                 {
                                    unique = false;
                                 }
                             }
                        }
                        if (unique)
                        {
                            intervalleDiagramme[j] = valeur;
                        }
                        j++;
                    } 
                }
                z++;
            }
            lecteurFichier.close();
    Thanks for your help,
    Ara

Similar Threads

  1. Duplicate Input Boxes
    By habester in forum New To Java
    Replies: 3
    Last Post: 11-09-2009, 07:13 PM
  2. Cannot insert duplicate key row in object
    By losintikfos in forum New To Java
    Replies: 3
    Last Post: 05-07-2009, 10:43 AM
  3. Duplicate XML decleration
    By gyl2009 in forum XML
    Replies: 0
    Last Post: 03-11-2009, 06:13 PM
  4. using loop to find duplicate
    By gwithey in forum New To Java
    Replies: 7
    Last Post: 03-06-2009, 02:46 PM
  5. Duplicate Files Remover
    By caps_lock in forum New To Java
    Replies: 0
    Last Post: 01-05-2009, 02:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •