Package org.apache.lucene.util
Class Sorter
java.lang.Object
org.apache.lucene.util.Sorter
- Direct Known Subclasses:
InPlaceMergeSorter
,IntroSorter
,MSBRadixSorter
,TimSorter
Base class for sorting algorithms implementations.
There are a number of subclasses to choose from that vary in performance and stability. We suggest that you pick the first from this ranked list that meets your requirements:
MSBRadixSorter
for strings (array of bytes/chars). Not a stable sort.StableMSBRadixSorter
for strings (array of bytes/chars). Stable sort.IntroSorter
. Not a stable sort.InPlaceMergeSorter
. When the data to sort is typically small. Stable sort.TimSorter
. Stable sort.
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract int
compare
(int i, int j) Compare entries found in slotsi
andj
.protected int
comparePivot
(int j) Compare the pivot with the slot atj
, similarly tocompare(i, j)
.protected void
setPivot
(int i) Save the value at sloti
so that it can later be used as a pivot, seecomparePivot(int)
.abstract void
sort
(int from, int to) Sort the slice which starts atfrom
(inclusive) and ends atto
(exclusive).protected abstract void
swap
(int i, int j) Swap values at slotsi
andj
.
-
Constructor Details
-
Sorter
protected Sorter()Sole constructor, used for inheritance.
-
-
Method Details
-
compare
protected abstract int compare(int i, int j) Compare entries found in slotsi
andj
. The contract for the returned value is the same asComparator.compare(Object, Object)
. -
swap
protected abstract void swap(int i, int j) Swap values at slotsi
andj
. -
setPivot
protected void setPivot(int i) Save the value at sloti
so that it can later be used as a pivot, seecomparePivot(int)
. -
comparePivot
protected int comparePivot(int j) Compare the pivot with the slot atj
, similarly tocompare(i, j)
. -
sort
public abstract void sort(int from, int to) Sort the slice which starts atfrom
(inclusive) and ends atto
(exclusive).
-