Class SortUtil
java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.Poisson.Octree.SortUtil
Quick and merge sort implementations that create no garbage, unlike
Arrays.sort(int[]). The merge sort is stable, the quick sort is not.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intThe size at or below which we will use insertion sort because it's probably faster. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidmsort(Object[] src, Object[] dest, int low, int high, int offset, Comparator comp) Implements the actual merge sort.static voidmsort(Object[] src, Object[] dest, int low, int high, Comparator comp) Merge sorts the supplied array using the specified comparator.static voidmsort(Object[] src, Object[] dest, Comparator comp) Merge sorts the supplied array using the specified comparator.static voidqsort(int[] a, int lo0, int hi0, Comparator comp) static voidqsort(Object[] a, int lo0, int hi0, Comparator comp) Quick sorts the supplied array using the specified comparator.static voidqsort(Object[] a, Comparator comp) Quick sorts the supplied array using the specified comparator.
-
Field Details
-
INSERTION_SORT_THRESHOLD
private static final int INSERTION_SORT_THRESHOLDThe size at or below which we will use insertion sort because it's probably faster.- See Also:
-
-
Constructor Details
-
SortUtil
public SortUtil()
-
-
Method Details
-
qsort
Quick sorts the supplied array using the specified comparator. -
qsort
Quick sorts the supplied array using the specified comparator.- Parameters:
lo0- the index of the lowest element to include in the sort.hi0- the index of the highest element to include in the sort.
-
qsort
-
msort
Merge sorts the supplied array using the specified comparator.- Parameters:
src- contains the elements to be sorted.dest- must contain the same values as the src array.
-
msort
Merge sorts the supplied array using the specified comparator.- Parameters:
src- contains the elements to be sorted.dest- must contain the same values as the src array.
-
msort
protected static void msort(Object[] src, Object[] dest, int low, int high, int offset, Comparator comp) Implements the actual merge sort.
-