fixing sort() methods so they are actually, you know, accurate... also ironing out Table bits

This commit is contained in:
Ben Fry
2013-04-29 09:45:30 -04:00
parent d7f2e5298f
commit 59b9cd573a
7 changed files with 225 additions and 75 deletions

View File

@@ -86,6 +86,16 @@ public class IntDict {
}
public IntDict(String[] keys, int[] values) {
if (keys.length != values.length) {
throw new IllegalArgumentException("key and value arrays must be the same length");
}
this.keys = keys;
this.values = values;
count = keys.length;
}
public int size() {
return count;
}
@@ -375,7 +385,7 @@ public class IntDict {
diff = keys[a].compareToIgnoreCase(keys[b]);
}
}
return reverse ? diff : -diff;
return reverse ? -diff : diff;
}
@Override
@@ -414,7 +424,7 @@ public class IntDict {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getName() + " size= " + size() + " { ");
sb.append(getClass().getSimpleName() + " size=" + size() + " { ");
for (int i = 0; i < size(); i++) {
if (i != 0) {
sb.append(", ");