JAL-845 minor tidy / tests / javadoc tweaks
[jalview.git] / src / jalview / util / QuickSort.java
index c28928d..cedf656 100755 (executable)
@@ -1,45 +1,83 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Copyright (C) 2014 The Jalview Authors
  * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
  * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
  * 
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.util;
 
+/**
+ * A class to perform efficient sorting of arrays of objects based on arrays of
+ * scores or other attributes. For example, residues by frequency.
+ * 
+ * @author gmcarstairs
+ *
+ */
 public class QuickSort
 {
+  /**
+   * Sorts both arrays with respect to ascending order of the items in the first
+   * array.
+   * 
+   * @param arr
+   * @param s
+   */
   public static void sort(int[] arr, Object[] s)
   {
     sort(arr, 0, arr.length - 1, s);
   }
+
+  /**
+   * Sorts both arrays with respect to ascending order of the items in the first
+   * array.
+   * 
+   * @param arr
+   * @param s
+   */
   public static void sort(float[] arr, Object[] s)
   {
     sort(arr, 0, arr.length - 1, s);
   }
 
+  /**
+   * Sorts both arrays with respect to ascending order of the items in the first
+   * array.
+   * 
+   * @param arr
+   * @param s
+   */
   public static void sort(double[] arr, Object[] s)
   {
     sort(arr, 0, arr.length - 1, s);
   }
 
+  /**
+   * Sorts both arrays with respect to descending order of the items in the
+   * first array.
+   * 
+   * @param arr
+   * @param s
+   */
   public static void sort(String[] arr, Object[] s)
   {
     stringSort(arr, 0, arr.length - 1, s);
   }
 
-  public static void stringSort(String[] arr, int p, int r, Object[] s)
+  static void stringSort(String[] arr, int p, int r, Object[] s)
   {
     int q;
 
@@ -51,7 +89,7 @@ public class QuickSort
     }
   }
 
-  public static void sort(float[] arr, int p, int r, Object[] s)
+  static void sort(float[] arr, int p, int r, Object[] s)
   {
     int q;
 
@@ -63,7 +101,7 @@ public class QuickSort
     }
   }
 
-  public static void sort(double[] arr, int p, int r, Object[] s)
+  static void sort(double[] arr, int p, int r, Object[] s)
   {
     int q;
 
@@ -74,7 +112,8 @@ public class QuickSort
       sort(arr, q + 1, r, s);
     }
   }
-  public static void sort(int[] arr, int p, int r, Object[] s)
+
+  static void sort(int[] arr, int p, int r, Object[] s)
   {
     int q;
 
@@ -86,7 +125,7 @@ public class QuickSort
     }
   }
 
-  private static int partition(float[] arr, int p, int r, Object[] s)
+  static int partition(float[] arr, int p, int r, Object[] s)
   {
     float x = arr[p];
     int i = p - 1;
@@ -120,8 +159,8 @@ public class QuickSort
       }
     }
   }
-  
-  private static int partition(int[] arr, int p, int r, Object[] s)
+
+  static int partition(int[] arr, int p, int r, Object[] s)
   {
     int x = arr[p];
     int i = p - 1;
@@ -156,7 +195,7 @@ public class QuickSort
     }
   }
 
-  private static int partition(double[] arr, int p, int r, Object[] s)
+  static int partition(double[] arr, int p, int r, Object[] s)
   {
     double x = arr[p];
     int i = p - 1;
@@ -191,7 +230,7 @@ public class QuickSort
     }
   }
 
-  private static int stringPartition(String[] arr, int p, int r, Object[] s)
+  static int stringPartition(String[] arr, int p, int r, Object[] s)
   {
     String x = arr[p];
     int i = p - 1;