arlut.csd.Util
Class QuickSort
java.lang.Object
|
+--arlut.csd.Util.QuickSort
- All Implemented Interfaces:
- Compare
- public class QuickSort
- extends java.lang.Object
- implements Compare
QuickSort implementation for Object array. Uses the
Compare interface for item
comparisons.
Algorithm from
Based on code by Eric van Bezooijen (eric@logrus.berkeley.edu)
and Roedy Green (roedy@bix.com).
|
Method Summary |
int |
compare(java.lang.Object a,
java.lang.Object b)
Default comparator, does a string comparison on the
toString() output of the objects for ordering. |
private int |
partition(int first,
int last)
Partition by splitting this chunk to sort in two and
get all big elements on one side of the pivot and all
the small elements on the other. |
private void |
quick(int first,
int last)
|
void |
sort()
|
private void |
swap(int i,
int j)
|
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
objects
java.lang.Object[] objects
comparator
Compare comparator
QuickSort
public QuickSort(java.lang.Object[] objects,
Compare comparator)
quick
private void quick(int first,
int last)
partition
private int partition(int first,
int last)
Partition by splitting this chunk to sort in two and
get all big elements on one side of the pivot and all
the small elements on the other.
swap
private void swap(int i,
int j)
sort
public void sort()
compare
public int compare(java.lang.Object a,
java.lang.Object b)
Default comparator, does a string comparison on the
toString() output of the objects for ordering.
- Specified by:
compare in interface Compare