A practical use case for this class is when the index of an array is meaningful and one wants
to acquire the order of values in that array. None of the methods in Java Collections would
provide such functionality directly and creating a collection of boxed Integer objects
for indices seems to be too costly.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static int | MIN_LENGTH_FOR_INSERTION_SORT
Minimum window length to apply insertion sort in merge sort. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static int[] | |
| private static void | insertionSort(final int off, final int len, int[] order, IntBinaryOperator intComparator)
Internal insertion sort for |
| public static int[] | mergesort(int start, int length, IntBinaryOperator comparator)
Returns the order of elements between indices |
| public static int[] | mergesort(int[] orderArray, IntBinaryOperator comparator)
Returns a sorted copy of the order array provided, using the given |
| public static <T> int[] | mergesort(T[] input, int start, int length, Comparator<? super T> comparator)
Returns the order of elements between indices |
| private static void | topDownMergeSort(int[] src, int[] dst, int
inclusive fromIndex, int exclusive toIndex, IntBinaryOperator comp)Perform a recursive, descending merge sort. |
| MIN_LENGTH_FOR_INSERTION_SORT | back to summary |
|---|---|
| pack-priv static int MIN_LENGTH_FOR_INSERTION_SORT Minimum window length to apply insertion sort in merge sort. | |
| IndirectSort | back to summary |
|---|---|
| private IndirectSort() No instantiation. | |
| createOrderArray | back to summary |
|---|---|
| private static int[] createOrderArray(final int start, final int length) Creates the initial order array. | |
| insertionSort | back to summary |
|---|---|
| private static void insertionSort(final int off, final int len, int[] order, IntBinaryOperator intComparator) Internal insertion sort for | |
| mergesort | back to summary |
|---|---|
| public static int[] mergesort(int start, int length, IntBinaryOperator comparator) Returns the order of elements between indices This routine uses merge sort. It is guaranteed to be stable. It creates a new indices array, and clones it while sorting. | |
| mergesort | back to summary |
|---|---|
| public static int[] mergesort(int[] orderArray, IntBinaryOperator comparator) Returns a sorted copy of the order array provided, using the given This routine uses merge sort. It is guaranteed to be stable. The provided | |
| mergesort | back to summary |
|---|---|
| public static <T> int[] mergesort(T[] input, int start, int length, Comparator<? super T> comparator) Returns the order of elements between indices This routine uses merge sort. It is guaranteed to be stable. It creates a new indices array, and clones it while sorting. | |
| topDownMergeSort | back to summary |
|---|---|
| private static void topDownMergeSort(int[] src, int[] dst, int fromIndex, int toIndex, IntBinaryOperator comp) Perform a recursive, descending merge sort.
| |