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.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidbinarySort(int from, int to) A binary sort implementation.(package private) voidbinarySort(int from, int to, int i) (package private) voidcheckRange(int from, int to) protected abstract intcompare(int i, int j) Compare entries found in slotsiandj.protected intcomparePivot(int j) Compare the pivot with the slot atj, similarly tocompare(i, j).(package private) voiddoRotate(int lo, int mid, int hi) (package private) static intheapChild(int from, int i) (package private) voidheapify(int from, int to) (package private) static intheapParent(int from, int i) (package private) voidheapSort(int from, int to) Use heap sort to sort items betweenfrominclusive andtoexclusive.(package private) intlower(int from, int to, int val) (package private) intlower2(int from, int to, int val) (package private) voidmergeInPlace(int from, int mid, int to) (package private) final voidreverse(int from, int to) (package private) final voidrotate(int lo, int mid, int hi) protected voidsetPivot(int i) Save the value at slotiso that it can later be used as a pivot, seecomparePivot(int).(package private) voidsiftDown(int i, int from, int to) abstract voidsort(int from, int to) Sort the slice which starts atfrom(inclusive) and ends atto(exclusive).protected abstract voidswap(int i, int j) Swap values at slotsiandj.(package private) intupper(int from, int to, int val) (package private) intupper2(int from, int to, int val)
-
Field Details
-
BINARY_SORT_THRESHOLD
static final int BINARY_SORT_THRESHOLD- See Also:
-
pivotIndex
private int pivotIndex
-
-
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 slotsiandj. 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 slotsiandj. -
setPivot
protected void setPivot(int i) Save the value at slotiso 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). -
checkRange
void checkRange(int from, int to) -
mergeInPlace
void mergeInPlace(int from, int mid, int to) -
lower
int lower(int from, int to, int val) -
upper
int upper(int from, int to, int val) -
lower2
int lower2(int from, int to, int val) -
upper2
int upper2(int from, int to, int val) -
reverse
final void reverse(int from, int to) -
rotate
final void rotate(int lo, int mid, int hi) -
doRotate
void doRotate(int lo, int mid, int hi) -
binarySort
void binarySort(int from, int to) A binary sort implementation. This performsO(n*log(n))comparisons andO(n^2)swaps. It is typically used by more sophisticated implementations as a fall-back when the numbers of items to sort has become less than 20. -
binarySort
void binarySort(int from, int to, int i) -
heapSort
void heapSort(int from, int to) Use heap sort to sort items betweenfrominclusive andtoexclusive. This runs inO(n*log(n))and is used as a fall-back byIntroSorter. -
heapify
void heapify(int from, int to) -
siftDown
void siftDown(int i, int from, int to) -
heapParent
static int heapParent(int from, int i) -
heapChild
static int heapChild(int from, int i)
-