Package org.apache.lucene.util
Class IntroSorter
- java.lang.Object
-
- org.apache.lucene.util.Sorter
-
- org.apache.lucene.util.IntroSorter
-
public abstract class IntroSorter extends Sorter
Sorterimplementation based on a variant of the quicksort algorithm called introsort: when the recursion level exceeds the log of the length of the array to sort, it falls back to heapsort. This prevents quicksort from running into its worst-case quadratic runtime. Small arrays are sorted with insertion sort.
-
-
Constructor Summary
Constructors Constructor Description IntroSorter()Create a newIntroSorter.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract intcomparePivot(int j)Compare the pivot with the slot atj, similarly tocompare(i, j).protected abstract voidsetPivot(int i)Save the value at slotiso that it can later be used as a pivot, seecomparePivot(int).voidsort(int from, int to)Sort the slice which starts atfrom(inclusive) and ends atto(exclusive).
-
-
-
Constructor Detail
-
IntroSorter
public IntroSorter()
Create a newIntroSorter.
-
-
Method Detail
-
sort
public final void sort(int from, int to)Description copied from class:SorterSort the slice which starts atfrom(inclusive) and ends atto(exclusive).
-
setPivot
protected abstract void setPivot(int i)
Save the value at slotiso that it can later be used as a pivot, seecomparePivot(int).
-
comparePivot
protected abstract int comparePivot(int j)
Compare the pivot with the slot atj, similarly tocompare(i, j).
-
-