Skip to content

Commit bcca2d5

Browse files
author
matthias.thimm
committed
bugfix
1 parent f8d0bd1 commit bcca2d5

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

org-tweetyproject-arg-rankings/src/main/java/org/tweetyproject/arg/rankings/util/LexicographicIntTupleComparator.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* This comparator compares tuples of integers according to the lexicographic ordering as described in
2525
* [Cayrol, Lagasquie-Schiex. Graduality in argumentation. 2005].
2626
*
27-
* @author Anna Gessler
27+
* @author Anna Gessler, Matthias Thimm
2828
*
2929
*/
3030
public class LexicographicIntTupleComparator implements Comparator<int[]> {
@@ -35,18 +35,28 @@ public class LexicographicIntTupleComparator implements Comparator<int[]> {
3535
public static final double PRECISION = 0.001;
3636
@Override
3737
public int compare(int[] o1, int[] o2) {
38-
String s1 = "";
39-
String s2 = "";
40-
for (int i : o1)
41-
s1 += i;
42-
for (int j : o2)
43-
s2 += j;
44-
return s1.compareTo(s2);
38+
int idx = 0;
39+
while(true) {
40+
if(o1.length == idx && o2.length == idx)
41+
return 0;
42+
if(o1.length == idx)
43+
return -1;
44+
if(o2.length == idx)
45+
return 1;
46+
47+
if(o1[idx] > o2[idx])
48+
return 1;
49+
if(o1[idx] < o2[idx])
50+
return -1;
51+
idx++;
52+
}
53+
4554
}
4655

4756

4857
/** Default Constructor */
49-
public LexicographicIntTupleComparator(){}
58+
public LexicographicIntTupleComparator(){}
59+
5060
}
5161

5262

0 commit comments

Comments
 (0)