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:
- The extra amount of memory to perform merges is
configurable. This allows small merges to be very fast while large merges
will be performed in-place (slightly slower). You can make sure that the
fast merge routine will always be used by having
maxTempSlots
equal to half of the length of the slice of data to sort. - Only the fast merge routine can gallop (the one that doesn't run in-place) and it only gallops on the longest slice.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Lucene.Net.Util
Assembly: Lucene.Net.dll
Syntax
public abstract class TimSorter : Sorter
Constructors
| Improve this Doc View SourceTimSorter(Int32)
Create a new TimSorter.
Declaration
protected TimSorter(int maxTempSlots)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxTempSlots |
Methods
| Improve this Doc View SourceCompareSaved(Int32, Int32)
Compare element i
from the temporary storage with element
j
from the slice to sort, similarly to
Compare(Int32, Int32).
Declaration
protected abstract int CompareSaved(int i, int j)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i | |
System.Int32 | j |
Returns
Type | Description |
---|---|
System.Int32 |
Copy(Int32, Int32)
Copy data from slot src
to slot dest
>.
Declaration
protected abstract void Copy(int src, int dest)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | src | |
System.Int32 | dest |
Restore(Int32, Int32)
Restore element j
from the temporary storage into slot i
.
Declaration
protected abstract void Restore(int i, int j)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i | |
System.Int32 | j |
Save(Int32, Int32)
Save all elements between slots i
and i
+len
into the temporary storage.
Declaration
protected abstract void Save(int i, int len)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i | |
System.Int32 | len |
Sort(Int32, Int32)
Sort the slice which starts at from
(inclusive) and ends at
to
(exclusive).
Declaration
public override void Sort(int from, int to)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | from | |
System.Int32 | to |