Package org.apache.hadoop.util
Class QuickSort
java.lang.Object
org.apache.hadoop.util.QuickSort
- All Implemented Interfaces:
IndexedSorter
An implementation of the core algorithm of QuickSort.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static intgetMaxDepth(int x) Deepest recursion before giving up and doing a heapsort.voidsort(IndexedSortable s, int p, int r) Sort the given range of items using quick sort.voidsort(IndexedSortable s, int p, int r, Progressable rep) Same asIndexedSorter.sort(IndexedSortable,int,int), but indicate progress periodically.
-
Constructor Details
-
QuickSort
public QuickSort()
-
-
Method Details
-
getMaxDepth
protected static int getMaxDepth(int x) Deepest recursion before giving up and doing a heapsort. Returns 2 * ceil(log(n)).- Parameters:
x- x.- Returns:
- MaxDepth.
-
sort
Sort the given range of items using quick sort. Sort the items accessed through the given IndexedSortable over the given range of logical indices. From the perspective of the sort algorithm, each index between l (inclusive) and r (exclusive) is an addressable entry. If the recursion depth falls belowgetMaxDepth(int), then switch toHeapSort.- Specified by:
sortin interfaceIndexedSorter- Parameters:
s- s.p- l.r- r.- See Also:
-
sort
Description copied from interface:IndexedSorterSame asIndexedSorter.sort(IndexedSortable,int,int), but indicate progress periodically.- Specified by:
sortin interfaceIndexedSorter- Parameters:
s- s.p- l.r- r.rep- rep.- See Also:
-