The sorting is not stable. Performance is O(n.log(n)) and memory is O(1) (although recursion memory is O(log(n))).
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | INSERTION_SORT_THRESHOLD
Below this size threshold, the sub-range is sorted using Insertion sort. |
| pack-priv static final int | SINGLE_MEDIAN_THRESHOLD
/** Below this size threshold, the partition selection is simplified to a single median. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static int | |
| private static void | insertionSort(int fromIndex, int toIndex, IntBinaryOperator comparator, IntBinaryOperator swapper)
Sorts between from (inclusive) and to (exclusive) with insertion sort. |
| private static int | median(int i, int j, int k, IntBinaryOperator comparator)
Returns the index of the median element among three elements at provided indices. |
| public static void | |
| public static void | |
| public static void | sort(int
Index where to start sorting in the array, inclusive. fromIndex, int Index where to stop sorting in the array, exclusive. toIndex, IntBinaryOperator Compares elements based on their indices. Given indices i and j in the
provided array, this comparator returns respectively -1/0/1 if the element at index i is
respectively less/equal/greater than the element at index j. comparator, IntBinaryOperator Swaps the elements in the array at the given indices. For example, a custom
swapper may allow sorting two arrays simultaneously. swapper)Performs a recursive in-place Quick sort. |
| private static void |
| INSERTION_SORT_THRESHOLD | back to summary |
|---|---|
| pack-priv static final int INSERTION_SORT_THRESHOLD Below this size threshold, the sub-range is sorted using Insertion sort. | |
| SINGLE_MEDIAN_THRESHOLD | back to summary |
|---|---|
| pack-priv static final int SINGLE_MEDIAN_THRESHOLD /** Below this size threshold, the partition selection is simplified to a single median. | |
| QuickSort | back to summary |
|---|---|
| private QuickSort() No instantiation. | |
| compare | back to summary |
|---|---|
| private static int compare(int i, int j, IntBinaryOperator comparator) Compares two elements at provided indices. | |
| insertionSort | back to summary |
|---|---|
| private static void insertionSort(int fromIndex, int toIndex, IntBinaryOperator comparator, IntBinaryOperator swapper) Sorts between from (inclusive) and to (exclusive) with insertion sort. | |
| median | back to summary |
|---|---|
| private static int median(int i, int j, int k, IntBinaryOperator comparator) Returns the index of the median element among three elements at provided indices. | |
| sort | back to summary |
|---|---|
| public static void sort(int[] array, IntBinaryOperator comparator) | |
| sort | back to summary |
|---|---|
| public static void sort(int[] array, int fromIndex, int toIndex, IntBinaryOperator comparator) | |
| sort | back to summary |
|---|---|
| public static void sort(int fromIndex, int toIndex, IntBinaryOperator comparator, IntBinaryOperator swapper) Performs a recursive in-place Quick sort. The sorting is not stable.
| |
| swap | back to summary |
|---|---|
| private static void swap(int i, int j, IntBinaryOperator swapper) Swaps two elements at provided indices. | |