Bonjour,

j ai un probleme lors de l utilsation de mon treeset.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
TreeSet treeSet = new TreeSet(new CandidatInscritParScoreHarmonisationComparator());	
		treeSet.addAll(dEtape.getCandidatsInscritEtape()); 
 
		//Recuperation de l'iterateur
		iter = treeSet.iterator();
dEtape.getCandidatsInscritsEtape() retourne un set de 20 candidatsInscritsEtape
mais lorsque j itere, il ne me ressort que 11candidats
Le probleme vient qu il y a des candidats ex -aequo (au sens de mon comparateur)


mon comparateur est defint comme suit, il gere les ex - eaquo

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
 
public class CandidatInscritParScoreHarmonisationComparator implements Comparator
{
 
    /**
     *
     */
 
    public int compare(Object arg0, Object arg1)
    {
        CandidatInscritEtape c0 = (CandidatInscritEtape) arg0;
        CandidatInscritEtape c1 = (CandidatInscritEtape) arg1;
 
      double d = c1.getScoreApresEtapeHarmonisation() - c2.getScoreApresEtapeHarmonisation();
 
        if (d < 0) return +1;
        if (d > 0) return -1;
        if (d == 0)
        {
            double[] scorePondere1 = c1.calculerScoreParPonderationHarmonisation(); 
            double[] scorePondere2 = c2.calculerScoreParPonderationHarmonisation();
 
            // on compare les notes pondérées, par prédominance. 
            for ( int i = 1; i < 5; i++ ) 
            {
                if (scorePondere1[i] - scorePondere2[2] < 0) return +1;
                if (scorePondere1[i] - scorePondere2[2] > 0) return -1;
            }
        }
        return 0;
    }     
 
        }
 
 
 
}

Je sais que c est un peu obscur mais il me samble avoir traiter les ex - eaquo avec le

Des idees?

le treeset est il compatible avec des ex - eaquo?

dois je chercher dans une autre direction

merci d avance