T
- type of sorted objectspublic class TimSort<T>
extends java.lang.Object
java.util.TimSort
(only for sorting Objects).
The workings of TimSort are described in a paper found under http://svn.python.org/projects/python/trunk/Objects/listsort.txt.
Here the algorithms are based on mutable indexables because this makes
implementations for lists, arrays and more work in the same way.
Also Ordering
is used instead of the standard Comparator
to make this more consistent
with the sister classes with sort primitive values.
TimSortDouble
,
TimSortFloat
,
TimSortInt
,
TimSortLong
Modifier and Type | Method and Description |
---|---|
(package private) static int |
mergeComputeMinrun(int n)
Compute a good value for the minimum run length.
|
static <E extends java.lang.Comparable<? super E>> |
sort(MutableIndexable<E> elements)
Sort the comparable elements of a mutable indexable in their natural order.
|
static <E> void |
sort(MutableIndexable<E> elements,
Ordering<? super E> order)
Sort a mutable indexable in the given order.
|
public static <E extends java.lang.Comparable<? super E>> void sort(@NotNull MutableIndexable<E> elements)
E
- element type of the indexableelements
- elements to sortpublic static <E> void sort(@NotNull MutableIndexable<E> elements, @NotNull Ordering<? super E> order)
E
- element type of the indexableelements
- elements to sortorder
- order defined for elementsjava.lang.IllegalArgumentException
- if order fails its invariantstatic int mergeComputeMinrun(int n)
n
if it is less than MIN_MERGE
because it's too small
for fancy stuff.
See http://svn.python.org/projects/python/trunk/Objects/listsort.txt for more info.
n
- size of remaining run