Opus5
Class AbstractQuickSorter
java.lang.Object
|
+--Opus5.AbstractSorter
|
+--Opus5.AbstractQuickSorter
- All Implemented Interfaces:
- Sorter
- Direct Known Subclasses:
- MedianOfThreeQuickSorter
- public abstract class AbstractQuickSorter
- extends AbstractSorter
The AbstractQuickSorter class is the base class
from which all concrete quick sorter classes are derived.
- Version:
- $Id: AbstractQuickSorter.java,v 3.2 1998/07/28 13:05:35 brpreiss Exp $
- Author:
- Bruno R. Preiss, P.Eng.
- See Also:
AbstractSorter,
MedianOfThreeQuickSorter
|
Field Summary |
protected static int |
cutOff
The length of the smallest array slice to quicksort. |
|
Method Summary |
protected abstract int |
selectPivot(int left,
int right)
Selects an element from the slice of the array between
the specified left and right positions
(inclusive) to serve as the pivot. |
protected void |
sort()
Sorts the array to which the array field refers. |
protected void |
sort(int left,
int right)
Recursively quicksorts the slide of the array between
the specified left and right positions. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cutOff
protected static final int cutOff
- The length of the smallest array slice to quicksort.
AbstractQuickSorter
public AbstractQuickSorter()
selectPivot
protected abstract int selectPivot(int left,
int right)
- Selects an element from the slice of the array between
the specified
left and right positions
(inclusive) to serve as the pivot.
- Parameters:
left - The position of the leftmost array element to consider.right - The position of the rightmost array element to consider.- Returns:
- The position of the pivot.
- See Also:
MedianOfThreeQuickSorter.selectPivot(int, int)
sort
protected void sort(int left,
int right)
- Recursively quicksorts the slide of the array between
the specified
left and right positions.
- Parameters:
left - The position of the leftmost element to be sorted.right - The position of the rightmost element to be sorted.
sort
protected void sort()
- Sorts the array to which the
array field refers.
Calls the recursive quicksort method to do the actual sort.
Since the recursive quicksort method stops short of finishing the sort,
this method uses a StraightInsertionSorter to finish the job.
- Overrides:
sort in class AbstractSorter
- See Also:
StraightInsertionSorter