Package sunlabs.brazil.util
Class Sort
- java.lang.Object
-
- sunlabs.brazil.util.Sort
-
public class Sort extends java.lang.ObjectPlaceholder for useful sorting utilities. Currently, sorting arrays and Vectors using the qsort algorithm are preovided.- Version:
- 2.2
- Author:
- Stephen Uhler (stephen.uhler@sun.com), Colin Stevens (colin.stevens@sun.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSort.CompareThis interface is used by theSortclass to compare elements when an array is being sorted.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidqsort(java.lang.Object array)Sorts an array of the basic types (ints, floats, bytes, etc.) or Strings.static voidqsort(java.lang.Object array, Sort.Compare compare)Sorts an array.static voidqsort(java.util.Vector strings)Sort a vector of strings using the Qsort algorithm.
-
-
-
Method Detail
-
qsort
public static void qsort(java.util.Vector strings)
Sort a vector of strings using the Qsort algorithm. The compareTo method of the String class is used for comparison.
-
qsort
public static void qsort(java.lang.Object array) throws java.lang.IllegalArgumentExceptionSorts an array of the basic types (ints, floats, bytes, etc.) or Strings. The sort is in increasing order, and is case-sensitive for strings. Sorting an array of booleans or an array of objects other than Strings is not supported.- Parameters:
array- The array to sort in place.- Throws:
java.lang.IllegalArgumentException- ifarrayis not an array of the types listed above.
-
qsort
public static void qsort(java.lang.Object array, Sort.Compare compare) throws java.lang.IllegalArgumentExceptionSorts an array. The specified comparator is used to control the sorting order. Arrays of any type may be sorted, depending upon what the comparator accepts.- Parameters:
array- The array to sort in place.compare- The comparator for sort order.- Throws:
java.lang.IllegalArgumentException- ifarrayis not an array.
-
-