public final class DualPivotQuicksort
extends java.lang.Object
Changes by Rammi: make this class public and allow user-defined order.
Because standard order tests for primitive types are fast operations
having a user-defined order makes sorting some 50% slower for these types.
For test purposes this also allows sorting generic indexables
like TimSort
, but tests show that
TimSort is faster in most cases.
Like standard quicksort this sorting algorithm is not stable.
Modifier and Type | Method and Description |
---|---|
static void |
sort(byte[] a,
ByteOrdering order)
Sorts the specified array in the specified order.
|
static void |
sort(byte[] a,
int left,
int right,
ByteOrdering order)
Sorts the specified range of the array in the specified order.
|
static void |
sort(char[] a,
CharOrdering order)
Sorts the specified array.
|
static void |
sort(char[] a,
int left,
int right,
CharOrdering order)
Sorts the specified range of the array.
|
static void |
sort(double[] a,
DoubleOrdering order)
Sorts the specified array according to the specified order.
|
static void |
sort(double[] a,
int left,
int right,
DoubleOrdering order)
Sorts the specified range of the array according to the specified order.
|
static void |
sort(float[] a,
FloatOrdering order)
Sorts the specified array using the specified order.
|
static void |
sort(float[] a,
int left,
int right,
FloatOrdering order)
Sorts the specified range of the array.
|
static void |
sort(int[] a,
int left,
int right,
IntOrdering order)
Sorts the specified range of the array.
|
static void |
sort(int[] a,
IntOrdering order)
Sorts the specified array.
|
static void |
sort(long[] a,
int left,
int right,
LongOrdering order)
Sorts the specified range of the array.
|
static void |
sort(long[] a,
LongOrdering order)
Sorts the specified array.
|
(package private) static <T> void |
sort(MutableIndexable<T> a,
Ordering<? super T> order)
Sorts the specified mutable int indexable by the given order.
|
static void |
sort(MutableIntIndexable a)
Sorts the specified mutable int indexable by the natural order of the elements.
|
static void |
sort(MutableIntIndexable a,
IntOrdering order)
Sorts the specified mutable int indexable by the given order.
|
static void |
sort(short[] a,
int left,
int right,
ShortOrdering order)
Sorts the specified range of the array.
|
static void |
sort(short[] a,
ShortOrdering order)
Sorts the specified array.
|
public static void sort(int[] a, @NotNull IntOrdering order)
a
- the array to be sortedorder
- user-defined orderpublic static void sort(int[] a, int left, int right, @NotNull IntOrdering order)
a
- the array to be sortedleft
- the index of the first element, inclusive, to be sortedright
- the index of the last element, inclusive, to be sortedorder
- user-defined orderpublic static void sort(long[] a, @NotNull LongOrdering order)
a
- the array to be sortedorder
- sort orderpublic static void sort(long[] a, int left, int right, @NotNull LongOrdering order)
a
- the array to be sortedleft
- the index of the first element, inclusive, to be sortedright
- the index of the last element, inclusive, to be sortedorder
- sort orderpublic static void sort(@NotNull short[] a, @NotNull ShortOrdering order)
a
- the array to be sortedorder
- sort orderpublic static void sort(@NotNull short[] a, int left, int right, @NotNull ShortOrdering order)
a
- the array to be sortedleft
- the index of the first element, inclusive, to be sortedright
- the index of the last element, inclusive, to be sortedorder
- sort orderpublic static void sort(@NotNull char[] a, @NotNull CharOrdering order)
a
- the array to be sortedorder
- sort orderpublic static void sort(@NotNull char[] a, int left, int right, @NotNull CharOrdering order)
a
- the array to be sortedleft
- the index of the first element, inclusive, to be sortedright
- the index of the last element, inclusive, to be sortedorder
- sort orderpublic static void sort(@NotNull byte[] a, @NotNull ByteOrdering order)
a
- the array to be sortedorder
- sort orderpublic static void sort(@NotNull byte[] a, int left, int right, @NotNull ByteOrdering order)
a
- the array to be sortedleft
- the index of the first element, inclusive, to be sortedright
- the index of the last element, inclusive, to be sortedorder
- sort orderpublic static void sort(@NotNull float[] a, @NotNull FloatOrdering order)
a
- the array to be sortedorder
- sort orderpublic static void sort(@NotNull float[] a, int left, int right, @NotNull FloatOrdering order)
a
- the array to be sortedleft
- the index of the first element, inclusive, to be sortedright
- the index of the last element, inclusive, to be sortedorder
- sort orderpublic static void sort(@NotNull double[] a, @NotNull DoubleOrdering order)
a
- the array to be sortedorder
- sort orderpublic static void sort(double[] a, int left, int right, @NotNull DoubleOrdering order)
a
- the array to be sortedleft
- the index of the first element, inclusive, to be sortedright
- the index of the last element, inclusive, to be sortedorder
- sort orderstatic <T> void sort(@NotNull MutableIndexable<T> a, @NotNull Ordering<? super T> order)
T
- element typea
- the indexable to be sortedorder
- user-defined orderpublic static void sort(@NotNull MutableIntIndexable a)
a
- the int indexable to be sortedpublic static void sort(@NotNull MutableIntIndexable a, @NotNull IntOrdering order)
a
- the indexable to be sortedorder
- user-defined order