Algorithm
Development Kit 1.0

algs.model.array
Class FirstSelector

java.lang.Object
  extended by algs.model.array.FirstSelector
All Implemented Interfaces:
IPivotIndex

public class FirstSelector
extends java.lang.Object
implements IPivotIndex

Quicksort selector during partition that selects leftmost element.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Constructor Summary
FirstSelector()
           
 
Method Summary
 int selectPivotIndex(java.lang.Comparable[] ar, int left, int right)
          Select leftmost index of ar[left,right] as the pivot index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FirstSelector

public FirstSelector()
Method Detail

selectPivotIndex

public int selectPivotIndex(java.lang.Comparable[] ar,
                            int left,
                            int right)
Select leftmost index of ar[left,right] as the pivot index.

Specified by:
selectPivotIndex in interface IPivotIndex
Parameters:
ar - base array of elements.
left - left index of sub-array
right - right index of sub-array
Returns:
an integer index value in the range [left,right] around which to pivot.

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.