calypso.util
Class QSort

java.lang.Object
  |
  +--calypso.util.QSort

public class QSort
extends java.lang.Object

Implements QuickSort, on an array of objects. An implementor of `Comparer' is passed in to compare two objects.


Constructor Summary
QSort(Comparer c)
          Create a QSort object.
 
Method Summary
 void sort(java.lang.Object[] list)
          Sorts the array, according to the Comparer.
 void sort(java.lang.Object[] list, int start, int end)
          Sorts a subsequence of the array, according to the Comparer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QSort

public QSort(Comparer c)
Create a QSort object. One way to use this would with dynamic class creation:
QSort sorter = new QSort(new Comparer() {
public int compare(Object a, Object b) {
if (a.key == b.key) return 0;
else if (a.key < b.key) return -1;
else return 1;
}
});
sorter.sort(array);
Method Detail

sort

public void sort(java.lang.Object[] list)
Sorts the array, according to the Comparer.

sort

public void sort(java.lang.Object[] list,
                 int start,
                 int end)
Sorts a subsequence of the array, according to the Comparer.