X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Futil%2FQuickSort.java;h=6901e244ca5af1f14edaddbf6cb09e39915b1eb2;hb=ce7b8a96b93ba7e22048c94ee907ca5655b72dcb;hp=c1ef153c48f4af2d7b567b7b105955bbaa784b4b;hpb=d616b0e1ac213a82591cece50ea25c5bfbfa865f;p=jalview.git diff --git a/src/jalview/util/QuickSort.java b/src/jalview/util/QuickSort.java index c1ef153..6901e24 100755 --- a/src/jalview/util/QuickSort.java +++ b/src/jalview/util/QuickSort.java @@ -51,8 +51,9 @@ public class QuickSort @Override public int compare(Integer o1, Integer o2) { - return ascending ? Float.compare(values[o1], values[o2]) : Float - .compare(values[o2], values[o1]); + return ascending + ? Float.compare(values[o1.intValue()], values[o2.intValue()]) + : Float.compare(values[o2.intValue()], values[o1.intValue()]); } } @@ -77,11 +78,11 @@ public class QuickSort { if (ascending) { - return Double.compare(values[o1], values[o2]); + return Double.compare(values[o1.intValue()], values[o2.intValue()]); } else { - return Double.compare(values[o2], values[o1]); + return Double.compare(values[o2.intValue()], values[o1.intValue()]); } } } @@ -105,8 +106,11 @@ public class QuickSort @Override public int compare(Integer o1, Integer o2) { - return ascending ? Integer.compare(values[o1], values[o2]) : Integer - .compare(values[o2], values[o1]); + return ascending + ? Integer.compare(values[o1.intValue()], + values[o2.intValue()]) + : Integer.compare(values[o2.intValue()], + values[o1.intValue()]); } } @@ -129,8 +133,9 @@ public class QuickSort @Override public int compare(Integer o1, Integer o2) { - return ascending ? values[o1].compareTo(values[o2]) : values[o2] - .compareTo(values[o1]); + return ascending + ? values[o1.intValue()].compareTo(values[o2.intValue()]) + : values[o2.intValue()].compareTo(values[o1.intValue()]); } } @@ -475,10 +480,10 @@ public class QuickSort /* * Copy sorted positive values after the negatives and zeros */ - System.arraycopy(nonZeroFloats, negativeCount, arr, negativeCount - + zerosCount, positiveCount); - System.arraycopy(nonZeroChars, negativeCount, s, negativeCount - + zerosCount, positiveCount); + System.arraycopy(nonZeroFloats, negativeCount, arr, + negativeCount + zerosCount, positiveCount); + System.arraycopy(nonZeroChars, negativeCount, s, + negativeCount + zerosCount, positiveCount); } /** @@ -613,10 +618,10 @@ public class QuickSort /* * Copy sorted positive values after the negatives and zeros */ - System.arraycopy(nonZeroInts, negativeCount, arr, negativeCount - + zerosCount, positiveCount); - System.arraycopy(nonZeroChars, negativeCount, s, negativeCount - + zerosCount, positiveCount); + System.arraycopy(nonZeroInts, negativeCount, arr, + negativeCount + zerosCount, positiveCount); + System.arraycopy(nonZeroChars, negativeCount, s, + negativeCount + zerosCount, positiveCount); } /** @@ -670,7 +675,7 @@ public class QuickSort final int length = arr.length; Integer[] indices = makeIndexArray(length); Arrays.sort(indices, new IntComparator(arr, ascending)); - + /* * Copy the array values as per the sorted indices */ @@ -681,7 +686,7 @@ public class QuickSort sortedInts[i] = arr[indices[i]]; sortedObjects[i] = s[indices[i]]; } - + /* * And copy the sorted values back into the arrays */ @@ -707,7 +712,7 @@ public class QuickSort final int length = arr.length; Integer[] indices = makeIndexArray(length); Arrays.sort(indices, new ExternalComparator(arr, ascending)); - + /* * Copy the array values as per the sorted indices */ @@ -718,7 +723,7 @@ public class QuickSort sortedStrings[i] = arr[indices[i]]; sortedObjects[i] = s[indices[i]]; } - + /* * And copy the sorted values back into the arrays */ @@ -743,7 +748,7 @@ public class QuickSort final int length = arr.length; Integer[] indices = makeIndexArray(length); Arrays.sort(indices, new DoubleComparator(arr, ascending)); - + /* * Copy the array values as per the sorted indices */ @@ -754,7 +759,7 @@ public class QuickSort sortedDoubles[i] = arr[indices[i]]; sortedObjects[i] = s[indices[i]]; } - + /* * And copy the sorted values back into the arrays */