|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.Sorter org.apache.lucene.util.TimSorter
public abstract class TimSorter
Sorter
implementation based on the
TimSort
algorithm.
This implementation is especially good at sorting partially-sorted arrays and sorts small arrays with binary sort.
NOTE:There are a few differences with the original implementation:
maxTempSlots
equal to half of the length of the slice of data to sort.
Constructor Summary | |
---|---|
protected |
TimSorter(int maxTempSlots)
Create a new TimSorter . |
Method Summary | |
---|---|
protected abstract int |
compareSaved(int i,
int j)
Compare element i from the temporary storage with element
j from the slice to sort, similarly to
Sorter.compare(int, int) . |
protected abstract void |
copy(int src,
int dest)
Copy data from slot src to slot dest . |
protected abstract void |
restore(int i,
int j)
Restore element j from the temporary storage into slot i . |
protected abstract void |
save(int i,
int len)
Save all elements between slots i and i+len
into the temporary storage. |
void |
sort(int from,
int to)
Sort the slice which starts at from (inclusive) and ends at
to (exclusive). |
Methods inherited from class org.apache.lucene.util.Sorter |
---|
compare, swap |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected TimSorter(int maxTempSlots)
TimSorter
.
maxTempSlots
- the maximum amount of extra memory to run mergesMethod Detail |
---|
public void sort(int from, int to)
Sorter
from
(inclusive) and ends at
to
(exclusive).
sort
in class Sorter
protected abstract void copy(int src, int dest)
src
to slot dest
.
protected abstract void save(int i, int len)
i
and i+len
into the temporary storage.
protected abstract void restore(int i, int j)
j
from the temporary storage into slot i
.
protected abstract int compareSaved(int i, int j)
i
from the temporary storage with element
j
from the slice to sort, similarly to
Sorter.compare(int, int)
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |