JAL-1807 Bob's first commit -- Applet loaded; needs image
[jalview.git] / src / jalview / util / QuickSort.java
index b0e75be..2a464c6 100755 (executable)
@@ -45,7 +45,7 @@ public class QuickSort
     @Override
     public int compare(Integer o1, Integer o2)
     {
-      return Float.compare(values[o1], values[o2]);
+      return Float.compare(values[o1.intValue()], values[o2]);
     }
     
   }
@@ -87,7 +87,7 @@ public class QuickSort
    * @param arr
    * @param s
    */
-  public static void sortFloat(float[] arr, Object[] s)
+  public static void sortFloatObject(float[] arr, Object[] s)
   {
     sortFloat(arr, 0, arr.length - 1, s);
   }
@@ -116,7 +116,7 @@ public class QuickSort
     stringSort(arr, 0, arr.length - 1, s);
   }
 
-  static void stringSort(String[] arr, int p, int r, Object[] s)
+  private static void stringSort(String[] arr, int p, int r, Object[] s)
   {
     int q;
 
@@ -128,7 +128,7 @@ public class QuickSort
     }
   }
 
-  static void sortFloat(float[] arr, int p, int r, Object[] s)
+  private static void sortFloat(float[] arr, int p, int r, Object[] s)
   {
     int q;
 
@@ -140,7 +140,17 @@ public class QuickSort
     }
   }
 
-  static void sortDouble(double[] arr, int p, int r, Object[] s)
+  /**
+   * We don't need both of these
+   * 
+   * @j2sIgnore
+   * 
+   * @param arr
+   * @param p
+   * @param r
+   * @param s
+   */
+         private static void sortDouble(double[] arr, int p, int r, Object[] s)
   {
     int q;
 
@@ -152,7 +162,7 @@ public class QuickSort
     }
   }
 
-  static void sortInt(int[] arr, int p, int r, Object[] s)
+  private static void sortInt(int[] arr, int p, int r, Object[] s)
   {
     int q;
 
@@ -164,7 +174,7 @@ public class QuickSort
     }
   }
 
-  static int partitionFloat(float[] arr, int p, int r, Object[] s)
+  private static int partitionFloat(float[] arr, int p, int r, Object[] s)
   {
     float x = arr[p];
     int i = p - 1;
@@ -199,7 +209,7 @@ public class QuickSort
     }
   }
 
-  static int partitionFloat(float[] arr, int p, int r, char[] s)
+  private static int partitionFloatChar(float[] arr, int p, int r, char[] s)
   {
     float x = arr[p];
     int i = p - 1;
@@ -234,7 +244,7 @@ public class QuickSort
     }
   }
 
-  static int partitionInt(int[] arr, int p, int r, Object[] s)
+  private static int partitionInt(int[] arr, int p, int r, Object[] s)
   {
     int x = arr[p];
     int i = p - 1;
@@ -269,7 +279,7 @@ public class QuickSort
     }
   }
 
-  static int partitionDouble(double[] arr, int p, int r, Object[] s)
+  private static int partitionDouble(double[] arr, int p, int r, Object[] s)
   {
     double x = arr[p];
     int i = p - 1;
@@ -304,7 +314,7 @@ public class QuickSort
     }
   }
 
-  static int stringPartition(String[] arr, int p, int r, Object[] s)
+  private static int stringPartition(String[] arr, int p, int r, Object[] s)
   {
     String x = arr[p];
     int i = p - 1;
@@ -346,7 +356,7 @@ public class QuickSort
    * @param arr
    * @param s
    */
-  public static void sortFloat(float[] arr, char[] s)
+  public static void sortFloatChar(float[] arr, char[] s)
   {
     /*
      * Sort all zero values to the front
@@ -388,7 +398,7 @@ public class QuickSort
     float[] nonZeroFloats = Arrays
             .copyOfRange(f1, nextZeroValue, f1.length);
     char[] nonZeroChars = Arrays.copyOfRange(s1, nextZeroValue, s1.length);
-    externalSort(nonZeroFloats, nonZeroChars);
+    externalSortFloat(nonZeroFloats, nonZeroChars);
     // sort(nonZeroFloats, 0, nonZeroFloats.length - 1, nonZeroChars);
 
     /*
@@ -409,7 +419,7 @@ public class QuickSort
    * @param arr
    * @param s
    */
-  protected static void externalSort(float[] arr, char[] s)
+  private static void externalSortFloat(float[] arr, char[] s)
   {
     final int length = arr.length;
     Integer[] indices = makeIndexArray(length);
@@ -439,7 +449,7 @@ public class QuickSort
    * @param length
    * @return
    */
-  protected static Integer[] makeIndexArray(final int length)
+  private  static Integer[] makeIndexArray(final int length)
   {
     Integer[] indices = new Integer[length];
     for (int i = 0; i < length; i++)
@@ -449,17 +459,17 @@ public class QuickSort
     return indices;
   }
 
-  static void sortFloat(float[] arr, int p, int r, char[] s)
-  {
-    int q;
-    if (p < r)
-    {
-      q = partitionFloat(arr, p, r, s);
-      sortFloat(arr, p, q, s);
-      sortFloat(arr, q + 1, r, s);
-    }
-  }
-
+//  private static void sortFloat(float[] arr, int p, int r, char[] s)
+//  {
+//    int q;
+//    if (p < r)
+//    {
+//      q = partitionFloatChar(arr, p, r, s);
+//      sortFloat(arr, p, q, s);
+//      sortFloat(arr, q + 1, r, s);
+//    }
+//  }
+//
   /**
    * Sorts both arrays to give ascending order in the first array, by first
    * partitioning into zero and non-zero values before sorting the latter.
@@ -467,7 +477,7 @@ public class QuickSort
    * @param arr
    * @param s
    */
-  public static void sortInt(int[] arr, char[] s)
+  public static void sortIntChar(int[] arr, char[] s)
   {
     /*
      * Sort all zero values to the front
@@ -509,7 +519,7 @@ public class QuickSort
     int[] nonZeroInts = Arrays
             .copyOfRange(f1, nextZeroValue, f1.length);
     char[] nonZeroChars = Arrays.copyOfRange(s1, nextZeroValue, s1.length);
-    externalSort(nonZeroInts, nonZeroChars);
+    externalSortInt(nonZeroInts, nonZeroChars);
     // sort(nonZeroFloats, 0, nonZeroFloats.length - 1, nonZeroChars);
   
     /*
@@ -529,7 +539,7 @@ public class QuickSort
    * @param arr
    * @param s
    */
-  protected static void externalSort(int[] arr, char[] s)
+  private static void externalSortInt(int[] arr, char[] s)
   {
     final int length = arr.length;
     Integer[] indices = makeIndexArray(length);