Class ArrayUtils

java.lang.Object
org.eclipse.mat.collect.ArrayUtils

public class ArrayUtils extends Object
Utility class for sorting arrays etc.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ArrayUtils

      public ArrayUtils()
  • Method Details

    • 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 sorting
      values - 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 sorting
      values - 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 sorting
      values - the values to be swapped with the corresponding keys
      tmpa - a temporary buffer at least as big as the keys
      tmpb - 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 sorting
      values - the values to be swapped with the corresponding keys
      offset - where in the arrays to start sorting
      length - how many keys (and values) from the offset to sort