java.lang.Object
com.carrotsearch.hppc.sorting.QuickSort
In-place Quick sort with 3-way partitioning and ending with Insertion sort.
The sorting is not stable. Performance is O(n.log(n)) and memory is O(1) (although recursion memory is O(log(n))).
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidsort(int[] array, int fromIndex, int toIndex, IntBinaryOperator comparator) static voidsort(int[] array, IntBinaryOperator comparator) static voidsort(int fromIndex, int toIndex, IntBinaryOperator comparator, IntBinaryOperator swapper) Performs a recursive in-place Quick sort.
-
Method Details
-
sort
- See Also:
-
sort
- See Also:
-
sort
public static void sort(int fromIndex, int toIndex, IntBinaryOperator comparator, IntBinaryOperator swapper) Performs a recursive in-place Quick sort. The sorting is not stable.- Parameters:
fromIndex- Index where to start sorting in the array, inclusive.toIndex- Index where to stop sorting in the array, exclusive.comparator- 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.swapper- Swaps the elements in the array at the given indices. For example, a custom swapper may allow sorting two arrays simultaneously.
-