Class ArrayUtils
- java.lang.Object
-
- org.eclipse.mat.collect.ArrayUtils
-
public class ArrayUtils extends java.lang.Object
Utility class for sorting arrays etc.
-
-
Constructor Summary
Constructors Constructor Description ArrayUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
sort(int[] keys, int[] values)
Sorts the keys in an increasing order.static void
sort(int[] keys, int[] values, int offset, int length)
Sorts a range from the keys in an increasing order.static void
sortDesc(long[] keys, int[] values)
Sorts the keys in an decreasing order.static void
sortDesc(long[] keys, int[] values, long[] tmpa, int[] tmpb)
Sorts the keys in an decreasing order.
-
-
-
Method Detail
-
sort
public static void sort(int[] keys, int[] values)
Sorts the keys in an increasing order. Elements key[i] and values[i] are always swapped together in the corresponding arrays.A mixture of several sorting algorithms is used:
A radix sort performs better on the numeric data we sort, but requires additional storage to perform the sorting. Therefore only the not-very-large parts produced by a quick sort are sorted with radix sort. An insertion sort is used to sort the smallest arrays, where the the overhead of the radix sort is also bigger
- Parameters:
keys
- the keys for sortingvalues
- the values to be swapped with the corresponding keys
-
sortDesc
public static void sortDesc(long[] keys, int[] values)
Sorts the keys in an decreasing order. Elements key[i] and values[i] are always swapped together in the corresponding arrays.A mixture of several sorting algorithms is used:
A radix sort performs better on the numeric data we sort, but requires additional storage to perform the sorting. Therefore only the not-very-large parts produced by a quick sort are sorted with radix sort. An insertion sort is used to sort the smallest arrays, where the the overhead of the radix sort is also bigger
- Parameters:
keys
- the keys for sortingvalues
- the values to be swapped with the corresponding keys
-
sortDesc
public static void sortDesc(long[] keys, int[] values, long[] tmpa, int[] tmpb)
Sorts the keys in an decreasing order. Elements key[i] and values[i] are always swapped together in the corresponding arrays.A mixture of several sorting algorithms is used:
A radix sort performs better on the numeric data we sort, but requires additional storage to perform the sorting. Therefore only the not-very-large parts produced by a quick sort are sorted with radix sort. An insertion sort is used to sort the smallest arrays, where the the overhead of the radix sort is also bigger
This version of the method allows the temporarily needed arrays for the radix sort to be provided externally - tempa and tempb. This saves unnecessary array creation and cleanup
- Parameters:
keys
- the keys for sortingvalues
- the values to be swapped with the corresponding keystmpa
- a temporary buffer at least as big as the keystmpb
- a temporary buffer at least as big as the keys/values
-
sort
public static void sort(int[] keys, int[] values, int offset, int length)
Sorts a range from the keys in an increasing order. Elements key[i] and values[i] are always swapped together in the corresponding arrays.A mixture of several sorting algorithms is used:
A radix sort performs better on the numeric data we sort, but requires additional storage to perform the sorting. Therefore only the not-very-large parts produced by a quick sort are sorted with radix sort. An insertion sort is used to sort the smallest arrays, where the the overhead of the radix sort is also bigger
- Parameters:
keys
- the keys for sortingvalues
- the values to be swapped with the corresponding keysoffset
- where in the arrays to start sortinglength
- how many keys (and values) from the offset to sort
-
-