Opus5
Class MedianOfThreeQuickSorter

java.lang.Object
  |
  +--Opus5.AbstractSorter
        |
        +--Opus5.AbstractQuickSorter
              |
              +--Opus5.MedianOfThreeQuickSorter
All Implemented Interfaces:
Sorter

public class MedianOfThreeQuickSorter
extends AbstractQuickSorter

Sorter for sorting an array of Comparable objects. Implements quicksort using median-of-three pivot selection.

Version:
$Id: MedianOfThreeQuickSorter.java,v 3.1 1998/07/28 01:32:17 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.
See Also:
Comparable

Fields inherited from class Opus5.AbstractQuickSorter
cutOff
 
Fields inherited from class Opus5.AbstractSorter
array, n
 
Fields inherited from interface Opus5.Sorter
copyright
 
Constructor Summary
MedianOfThreeQuickSorter()
           
 
Method Summary
protected  int selectPivot(int left, int right)
          Selects an element in the specified range of the array to serve as the pivot.
 
Methods inherited from class Opus5.AbstractQuickSorter
sort, sort
 
Methods inherited from class Opus5.AbstractSorter
sort, swap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MedianOfThreeQuickSorter

public MedianOfThreeQuickSorter()
Method Detail

selectPivot

protected int selectPivot(int left,
                          int right)
Selects an element in the specified range of the array to serve as the pivot.
Overrides:
selectPivot in class AbstractQuickSorter
Parameters:
left - The leftmost element of the range to consider.
right - The rightmost element of the range to consider.
Returns:
The position of the pivot.