sunlabs.brazil.util
Class Sort

java.lang.Object
  extended by sunlabs.brazil.util.Sort (view source)

public class Sort
extends Object

Placeholder for useful sorting utilities. Currently, sorting arrays and Vectors using the qsort algorithm are preovided.


Nested Class Summary
static interface Sort.Compare
          This interface is used by the Sort class to compare elements when an array is being sorted.
 
Method Summary
static void qsort(Object array)
          Sorts an array of the basic types (ints, floats, bytes, etc.) or Strings.
static void qsort(Object array, Sort.Compare compare)
          Sorts an array.
static void qsort(Vector strings)
          Sort a vector of strings using the Qsort algorithm.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

qsort

public static void qsort(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(Object array)
                  throws IllegalArgumentException
Sorts 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:
IllegalArgumentException - if array is not an array of the types listed above.

qsort

public static void qsort(Object array,
                         Sort.Compare compare)
                  throws IllegalArgumentException
Sorts 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:
IllegalArgumentException - if array is not an array.

Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.