Class FloatArrays

java.lang.Object
it.unimi.dsi.fastutil.floats.FloatArrays

public final class FloatArrays extends Object
A class providing static methods and objects that do useful things with type-specific arrays.

In particular, the forceCapacity(), ensureCapacity(), grow(), trim() and setLength() methods allow to handle arrays much like array lists. This can be very useful when efficiency (or syntactic simplicity) reasons make array lists unsuitable.

Note that BinIO and TextIO contain several methods make it possible to load and save arrays of primitive types as sequences of elements in DataInput format (i.e., not as objects) or as sequences of lines of text.

Sorting

There are several sorting methods available. The main theme is that of letting you choose the sorting algorithm you prefer (i.e., trading stability of mergesort for no memory allocation in quicksort).

Parallel operations

Some algorithms provide a parallel version that will by default use the common pool, but this can be overridden by calling the function in a task already in the ForkJoinPool that the operation should run in. For example, something along the lines of "poolToParallelSortIn.invoke(() -> parallelQuickSort(arrayToSort))" will run the parallel sort in poolToParallelSortIn instead of the default pool. Some algorithms also provide an explicit indirect sorting facility, which makes it possible to sort an array using the values in another array as comparator.

However, if you wish to let the implementation choose an algorithm for you, both stableSort(float[], int, int) and unstableSort(float[], int, int) methods are available, which dynamically chooses an algorithm based on unspecified criteria (but most likely stability, array size, and array element type).

All comparison-based algorithm have an implementation based on a type-specific comparator.

As a general rule, sequential radix sort is significantly faster than quicksort or mergesort, in particular on random-looking data. In the parallel case, up to a few cores parallel radix sort is still the fastest, but at some point quicksort exploits parallelism better.

If you are fine with not knowing exactly which algorithm will be run (in particular, not knowing exactly whether a support array will be allocated), the dual-pivot parallel sorts in Arrays are about 50% faster than the classical single-pivot implementation used here.

In any case, if sorting time is important I suggest that you benchmark your sorting load with your data distribution and on your architecture.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final float[]
    A static, final, empty array to be used as default array in allocations.
    static final float[]
    A static, final, empty array.
    static final Hash.Strategy<float[]>
    A type-specific content-based hash strategy for arrays.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    binarySearch(float[] a, float key)
    Searches an array for the specified value using the binary search algorithm.
    static int
    binarySearch(float[] a, float key, FloatComparator c)
    Searches an array for the specified value using the binary search algorithm and a specified comparator.
    static int
    binarySearch(float[] a, int from, int to, float key)
    Searches a range of the specified array for the specified value using the binary search algorithm.
    static int
    binarySearch(float[] a, int from, int to, float key, FloatComparator c)
    Searches a range of the specified array for the specified value using the binary search algorithm and a specified comparator.
    static float[]
    copy(float[] array)
    Returns a copy of an array.
    static float[]
    copy(float[] array, int offset, int length)
    Returns a copy of a portion of an array.
    static float[]
    ensureCapacity(float[] array, int length)
    Ensures that an array can contain the given number of entries.
    static float[]
    ensureCapacity(float[] array, int length, int preserve)
    Ensures that an array can contain the given number of entries, preserving just a part of the array.
    static void
    ensureFromTo(float[] a, int from, int to)
    Ensures that a range given by its first (inclusive) and last (exclusive) elements fits an array.
    static void
    ensureOffsetLength(float[] a, int offset, int length)
    Ensures that a range given by an offset and a length fits an array.
    static void
    ensureSameLength(float[] a, float[] b)
    Ensures that two arrays are of the same length.
    static boolean
    equals(float[] a1, float[] a2)
    Deprecated.
    Please use the corresponding Arrays method, which is intrinsified in recent JVMs.
    static void
    fill(float[] array, float value)
    Deprecated.
    Please use the corresponding Arrays method.
    static void
    fill(float[] array, int from, int to, float value)
    Deprecated.
    Please use the corresponding Arrays method.
    static float[]
    forceCapacity(float[] array, int length, int preserve)
    Forces an array to contain the given number of entries, preserving just a part of the array.
    static float[]
    grow(float[] array, int length)
    Grows the given array to the maximum between the given length and the current length increased by 50%, provided that the given length is larger than the current length.
    static float[]
    grow(float[] array, int length, int preserve)
    Grows the given array to the maximum between the given length and the current length increased by 50%, provided that the given length is larger than the current length, preserving just a part of the array.
    static void
    mergeSort(float[] a)
    Sorts an array according to the natural ascending order using mergesort.
    static void
    mergeSort(float[] a, int from, int to)
    Sorts the specified range of elements according to the natural ascending order using mergesort.
    static void
    mergeSort(float[] a, int from, int to, float[] supp)
    Sorts the specified range of elements according to the natural ascending order using mergesort, using a given pre-filled support array.
    static void
    mergeSort(float[] a, int from, int to, FloatComparator comp)
    Sorts the specified range of elements according to the order induced by the specified comparator using mergesort.
    static void
    mergeSort(float[] a, int from, int to, FloatComparator comp, float[] supp)
    Sorts the specified range of elements according to the order induced by the specified comparator using mergesort, using a given pre-filled support array.
    static void
    mergeSort(float[] a, FloatComparator comp)
    Sorts an array according to the order induced by the specified comparator using mergesort.
    static void
    parallelQuickSort(float[] x)
    Sorts an array according to the natural ascending order using a parallel quicksort.
    static void
    parallelQuickSort(float[] x, float[] y)
    Sorts two arrays according to the natural lexicographical ascending order using a parallel quicksort.
    static void
    parallelQuickSort(float[] x, float[] y, int from, int to)
    Sorts the specified range of elements of two arrays according to the natural lexicographical ascending order using a parallel quicksort.
    static void
    parallelQuickSort(float[] x, int from, int to)
    Sorts the specified range of elements according to the natural ascending order using a parallel quicksort.
    static void
    parallelQuickSort(float[] x, int from, int to, FloatComparator comp)
    Sorts the specified range of elements according to the order induced by the specified comparator using a parallel quicksort.
    static void
    Sorts an array according to the order induced by the specified comparator using a parallel quicksort.
    static void
    parallelQuickSortIndirect(int[] perm, float[] x)
    Sorts an array according to the natural ascending order using a parallel indirect quicksort.
    static void
    parallelQuickSortIndirect(int[] perm, float[] x, int from, int to)
    Sorts the specified range of elements according to the natural ascending order using a parallel indirect quicksort.
    static void
    parallelRadixSort(float[] a)
    Sorts the specified array using parallel radix sort.
    static void
    parallelRadixSort(float[] a, float[] b)
    Sorts two arrays using a parallel radix sort.
    static void
    parallelRadixSort(float[] a, float[] b, int from, int to)
    Sorts the specified range of elements of two arrays using a parallel radix sort.
    static void
    parallelRadixSort(float[] a, int from, int to)
    Sorts the specified range of an array using parallel radix sort.
    static void
    parallelRadixSortIndirect(int[] perm, float[] a, boolean stable)
    Sorts the specified array using parallel indirect radix sort.
    static void
    parallelRadixSortIndirect(int[] perm, float[] a, int from, int to, boolean stable)
    Sorts the specified range of an array using parallel indirect radix sort.
    static void
    quickSort(float[] x)
    Sorts an array according to the natural ascending order using quicksort.
    static void
    quickSort(float[] x, float[] y)
    Sorts two arrays according to the natural lexicographical ascending order using quicksort.
    static void
    quickSort(float[] x, float[] y, int from, int to)
    Sorts the specified range of elements of two arrays according to the natural lexicographical ascending order using quicksort.
    static void
    quickSort(float[] x, int from, int to)
    Sorts the specified range of elements according to the natural ascending order using quicksort.
    static void
    quickSort(float[] x, int from, int to, FloatComparator comp)
    Sorts the specified range of elements according to the order induced by the specified comparator using quicksort.
    static void
    quickSort(float[] x, FloatComparator comp)
    Sorts an array according to the order induced by the specified comparator using quicksort.
    static void
    quickSortIndirect(int[] perm, float[] x)
    Sorts an array according to the natural ascending order using indirect quicksort.
    static void
    quickSortIndirect(int[] perm, float[] x, int from, int to)
    Sorts the specified range of elements according to the natural ascending order using indirect quicksort.
    static void
    radixSort(float[] a)
    Sorts the specified array using radix sort.
    static void
    radixSort(float[][] a)
    Sorts the specified array of arrays lexicographically using radix sort.
    static void
    radixSort(float[][] a, int from, int to)
    Sorts the specified array of arrays lexicographically using radix sort.
    static void
    radixSort(float[] a, float[] b)
    Sorts the specified pair of arrays lexicographically using radix sort.
    static void
    radixSort(float[] a, float[] b, int from, int to)
    Sorts the specified range of elements of two arrays using radix sort.
    static void
    radixSort(float[] a, int from, int to)
    Sorts the specified range of an array using radix sort.
    static void
    radixSortIndirect(int[] perm, float[] a, boolean stable)
    Sorts the specified array using indirect radix sort.
    static void
    radixSortIndirect(int[] perm, float[] a, float[] b, boolean stable)
    Sorts the specified pair of arrays lexicographically using indirect radix sort.
    static void
    radixSortIndirect(int[] perm, float[] a, float[] b, int from, int to, boolean stable)
    Sorts the specified pair of arrays lexicographically using indirect radix sort.
    static void
    radixSortIndirect(int[] perm, float[] a, int from, int to, boolean stable)
    Sorts the specified array using indirect radix sort.
    static float[]
    reverse(float[] a)
    Reverses the order of the elements in the specified array.
    static float[]
    reverse(float[] a, int from, int to)
    Reverses the order of the elements in the specified array fragment.
    static float[]
    setLength(float[] array, int length)
    Sets the length of the given array.
    static float[]
    shuffle(float[] a, int from, int to, Random random)
    Shuffles the specified array fragment using the specified pseudorandom number generator.
    static float[]
    shuffle(float[] a, Random random)
    Shuffles the specified array using the specified pseudorandom number generator.
    static void
    stabilize(int[] perm, float[] x)
    Stabilizes a permutation.
    static void
    stabilize(int[] perm, float[] x, int from, int to)
    Stabilizes a permutation.
    static void
    stableSort(float[] a)
    Sorts the specified range of elements according to the natural ascending order potentially dynamically choosing an appropriate algorithm given the type and size of the array.
    static void
    stableSort(float[] a, int from, int to)
    Sorts an array according to the natural ascending order, potentially dynamically choosing an appropriate algorithm given the type and size of the array.
    static void
    stableSort(float[] a, int from, int to, FloatComparator comp)
    Sorts the specified range of elements according to the order induced by the specified comparator, potentially dynamically choosing an appropriate algorithm given the type and size of the array.
    static void
    stableSort(float[] a, FloatComparator comp)
    Sorts an array according to the order induced by the specified comparator, potentially dynamically choosing an appropriate algorithm given the type and size of the array.
    static void
    swap(float[] x, int a, int b)
    Swaps two elements of an anrray.
    static void
    swap(float[] x, int a, int b, int n)
    Swaps two sequences of elements of an array.
    static float[]
    trim(float[] array, int length)
    Trims the given array to the given length.
    static void
    unstableSort(float[] a)
    Sorts the specified range of elements according to the natural ascending order potentially dynamically choosing an appropriate algorithm given the type and size of the array.
    static void
    unstableSort(float[] a, int from, int to)
    Sorts an array according to the natural ascending order, potentially dynamically choosing an appropriate algorithm given the type and size of the array.
    static void
    unstableSort(float[] a, int from, int to, FloatComparator comp)
    Sorts the specified range of elements according to the order induced by the specified comparator, potentially dynamically choosing an appropriate algorithm given the type and size of the array.
    static void
    unstableSort(float[] a, FloatComparator comp)
    Sorts an array according to the order induced by the specified comparator, potentially dynamically choosing an appropriate algorithm given the type and size of the array.

    Methods inherited from class java.lang.Object

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

    • EMPTY_ARRAY

      public static final float[] EMPTY_ARRAY
      A static, final, empty array.
    • DEFAULT_EMPTY_ARRAY

      public static final float[] DEFAULT_EMPTY_ARRAY
      A static, final, empty array to be used as default array in allocations. An object distinct from EMPTY_ARRAY makes it possible to have different behaviors depending on whether the user required an empty allocation, or we are just lazily delaying allocation.
      See Also:
    • HASH_STRATEGY

      public static final Hash.Strategy<float[]> HASH_STRATEGY
      A type-specific content-based hash strategy for arrays.

      This hash strategy may be used in custom hash collections whenever keys are arrays, and they must be considered equal by content. This strategy will handle null correctly, and it is serializable.

  • Method Details

    • forceCapacity

      public static float[] forceCapacity(float[] array, int length, int preserve)
      Forces an array to contain the given number of entries, preserving just a part of the array.
      Parameters:
      array - an array.
      length - the new minimum length for this array.
      preserve - the number of elements of the array that must be preserved in case a new allocation is necessary.
      Returns:
      an array with length entries whose first preserve entries are the same as those of array.
    • ensureCapacity

      public static float[] ensureCapacity(float[] array, int length)
      Ensures that an array can contain the given number of entries.

      If you cannot foresee whether this array will need again to be enlarged, you should probably use grow() instead.

      Parameters:
      array - an array.
      length - the new minimum length for this array.
      Returns:
      array, if it contains length entries or more; otherwise, an array with length entries whose first array.length entries are the same as those of array.
    • ensureCapacity

      public static float[] ensureCapacity(float[] array, int length, int preserve)
      Ensures that an array can contain the given number of entries, preserving just a part of the array.
      Parameters:
      array - an array.
      length - the new minimum length for this array.
      preserve - the number of elements of the array that must be preserved in case a new allocation is necessary.
      Returns:
      array, if it can contain length entries or more; otherwise, an array with length entries whose first preserve entries are the same as those of array.
    • grow

      public static float[] grow(float[] array, int length)
      Grows the given array to the maximum between the given length and the current length increased by 50%, provided that the given length is larger than the current length.

      If you want complete control on the array growth, you should probably use ensureCapacity() instead.

      Parameters:
      array - an array.
      length - the new minimum length for this array.
      Returns:
      array, if it can contain length entries; otherwise, an array with max(length,array.length/φ) entries whose first array.length entries are the same as those of array.
    • grow

      public static float[] grow(float[] array, int length, int preserve)
      Grows the given array to the maximum between the given length and the current length increased by 50%, provided that the given length is larger than the current length, preserving just a part of the array.

      If you want complete control on the array growth, you should probably use ensureCapacity() instead.

      Parameters:
      array - an array.
      length - the new minimum length for this array.
      preserve - the number of elements of the array that must be preserved in case a new allocation is necessary.
      Returns:
      array, if it can contain length entries; otherwise, an array with max(length,array.length/φ) entries whose first preserve entries are the same as those of array.
    • trim

      public static float[] trim(float[] array, int length)
      Trims the given array to the given length.
      Parameters:
      array - an array.
      length - the new maximum length for the array.
      Returns:
      array, if it contains length entries or less; otherwise, an array with length entries whose entries are the same as the first length entries of array.
    • setLength

      public static float[] setLength(float[] array, int length)
      Sets the length of the given array.
      Parameters:
      array - an array.
      length - the new length for the array.
      Returns:
      array, if it contains exactly length entries; otherwise, if it contains more than length entries, an array with length entries whose entries are the same as the first length entries of array; otherwise, an array with length entries whose first array.length entries are the same as those of array.
    • copy

      public static float[] copy(float[] array, int offset, int length)
      Returns a copy of a portion of an array.
      Parameters:
      array - an array.
      offset - the first element to copy.
      length - the number of elements to copy.
      Returns:
      a new array containing length elements of array starting at offset.
    • copy

      public static float[] copy(float[] array)
      Returns a copy of an array.
      Parameters:
      array - an array.
      Returns:
      a copy of array.
    • fill

      @Deprecated public static void fill(float[] array, float value)
      Deprecated.
      Please use the corresponding Arrays method.
      Fills the given array with the given value.
      Parameters:
      array - an array.
      value - the new value for all elements of the array.
    • fill

      @Deprecated public static void fill(float[] array, int from, int to, float value)
      Deprecated.
      Please use the corresponding Arrays method.
      Fills a portion of the given array with the given value.
      Parameters:
      array - an array.
      from - the starting index of the portion to fill (inclusive).
      to - the end index of the portion to fill (exclusive).
      value - the new value for all elements of the specified portion of the array.
    • equals

      @Deprecated public static boolean equals(float[] a1, float[] a2)
      Deprecated.
      Please use the corresponding Arrays method, which is intrinsified in recent JVMs.
      Returns true if the two arrays are elementwise equal.
      Parameters:
      a1 - an array.
      a2 - another array.
      Returns:
      true if the two arrays are of the same length, and their elements are equal.
    • ensureFromTo

      public static void ensureFromTo(float[] a, int from, int to)
      Ensures that a range given by its first (inclusive) and last (exclusive) elements fits an array.

      This method may be used whenever an array range check is needed.

      In Java 9 and up, this method should be considered deprecated in favor of the Objects.checkFromToIndex(int, int, int) method, which may be intrinsified in recent JVMs.

      Parameters:
      a - an array.
      from - a start index (inclusive).
      to - an end index (exclusive).
      Throws:
      IllegalArgumentException - if from is greater than to.
      ArrayIndexOutOfBoundsException - if from or to are greater than the array length or negative.
    • ensureOffsetLength

      public static void ensureOffsetLength(float[] a, int offset, int length)
      Ensures that a range given by an offset and a length fits an array.

      This method may be used whenever an array range check is needed.

      In Java 9 and up, this method should be considered deprecated in favor of the Objects.checkFromIndexSize(int, int, int) method, which may be intrinsified in recent JVMs.

      Parameters:
      a - an array.
      offset - a start index.
      length - a length (the number of elements in the range).
      Throws:
      IllegalArgumentException - if length is negative.
      ArrayIndexOutOfBoundsException - if offset is negative or offset+length is greater than the array length.
    • ensureSameLength

      public static void ensureSameLength(float[] a, float[] b)
      Ensures that two arrays are of the same length.
      Parameters:
      a - an array.
      b - another array.
      Throws:
      IllegalArgumentException - if the two argument arrays are not of the same length.
    • swap

      public static void swap(float[] x, int a, int b)
      Swaps two elements of an anrray.
      Parameters:
      x - an array.
      a - a position in x.
      b - another position in x.
    • swap

      public static void swap(float[] x, int a, int b, int n)
      Swaps two sequences of elements of an array.
      Parameters:
      x - an array.
      a - a position in x.
      b - another position in x.
      n - the number of elements to exchange starting at a and b.
    • quickSort

      public static void quickSort(float[] x, int from, int to, FloatComparator comp)
      Sorts the specified range of elements according to the order induced by the specified comparator using quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      Note that this implementation does not allocate any object, contrarily to the implementation used to sort primitive types in Arrays, which switches to mergesort on large inputs.

      Parameters:
      x - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      comp - the comparator to determine the sorting order.
    • quickSort

      public static void quickSort(float[] x, FloatComparator comp)
      Sorts an array according to the order induced by the specified comparator using quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      Note that this implementation does not allocate any object, contrarily to the implementation used to sort primitive types in Arrays, which switches to mergesort on large inputs.

      Parameters:
      x - the array to be sorted.
      comp - the comparator to determine the sorting order.
    • parallelQuickSort

      public static void parallelQuickSort(float[] x, int from, int to, FloatComparator comp)
      Sorts the specified range of elements according to the order induced by the specified comparator using a parallel quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      Parameters:
      x - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      comp - the comparator to determine the sorting order.
    • parallelQuickSort

      public static void parallelQuickSort(float[] x, FloatComparator comp)
      Sorts an array according to the order induced by the specified comparator using a parallel quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      Parameters:
      x - the array to be sorted.
      comp - the comparator to determine the sorting order.
    • quickSort

      public static void quickSort(float[] x, int from, int to)
      Sorts the specified range of elements according to the natural ascending order using quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      Note that this implementation does not allocate any object, contrarily to the implementation used to sort primitive types in Arrays, which switches to mergesort on large inputs.

      Parameters:
      x - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • quickSort

      public static void quickSort(float[] x)
      Sorts an array according to the natural ascending order using quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      Note that this implementation does not allocate any object, contrarily to the implementation used to sort primitive types in Arrays, which switches to mergesort on large inputs.

      Parameters:
      x - the array to be sorted.
    • parallelQuickSort

      public static void parallelQuickSort(float[] x, int from, int to)
      Sorts the specified range of elements according to the natural ascending order using a parallel quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      Parameters:
      x - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • parallelQuickSort

      public static void parallelQuickSort(float[] x)
      Sorts an array according to the natural ascending order using a parallel quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      Parameters:
      x - the array to be sorted.
    • quickSortIndirect

      public static void quickSortIndirect(int[] perm, float[] x, int from, int to)
      Sorts the specified range of elements according to the natural ascending order using indirect quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that x[perm[i]] &le; x[perm[i + 1]].

      Note that this implementation does not allocate any object, contrarily to the implementation used to sort primitive types in Arrays, which switches to mergesort on large inputs.

      Parameters:
      perm - a permutation array indexing x.
      x - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • quickSortIndirect

      public static void quickSortIndirect(int[] perm, float[] x)
      Sorts an array according to the natural ascending order using indirect quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that x[perm[i]] &le; x[perm[i + 1]].

      Note that this implementation does not allocate any object, contrarily to the implementation used to sort primitive types in Arrays, which switches to mergesort on large inputs.

      Parameters:
      perm - a permutation array indexing x.
      x - the array to be sorted.
    • parallelQuickSortIndirect

      public static void parallelQuickSortIndirect(int[] perm, float[] x, int from, int to)
      Sorts the specified range of elements according to the natural ascending order using a parallel indirect quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that x[perm[i]] &le; x[perm[i + 1]].

      Parameters:
      perm - a permutation array indexing x.
      x - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • parallelQuickSortIndirect

      public static void parallelQuickSortIndirect(int[] perm, float[] x)
      Sorts an array according to the natural ascending order using a parallel indirect quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that x[perm[i]] &le; x[perm[i + 1]].

      Parameters:
      perm - a permutation array indexing x.
      x - the array to be sorted.
    • stabilize

      public static void stabilize(int[] perm, float[] x, int from, int to)
      Stabilizes a permutation.

      This method can be used to stabilize the permutation generated by an indirect sorting, assuming that initially the permutation array was in ascending order (e.g., the identity, as usually happens). This method scans the permutation, and for each non-singleton block of elements with the same associated values in x, permutes them in ascending order. The resulting permutation corresponds to a stable sort.

      Usually combining an unstable indirect sort and this method is more efficient than using a stable sort, as most stable sort algorithms require a support array.

      More precisely, assuming that x[perm[i]] &le; x[perm[i + 1]], after stabilization we will also have that x[perm[i]] = x[perm[i + 1]] implies perm[i] &le; perm[i + 1].

      Parameters:
      perm - a permutation array indexing x so that it is sorted.
      x - the sorted array to be stabilized.
      from - the index of the first element (inclusive) to be stabilized.
      to - the index of the last element (exclusive) to be stabilized.
    • stabilize

      public static void stabilize(int[] perm, float[] x)
      Stabilizes a permutation.

      This method can be used to stabilize the permutation generated by an indirect sorting, assuming that initially the permutation array was in ascending order (e.g., the identity, as usually happens). This method scans the permutation, and for each non-singleton block of elements with the same associated values in x, permutes them in ascending order. The resulting permutation corresponds to a stable sort.

      Usually combining an unstable indirect sort and this method is more efficient than using a stable sort, as most stable sort algorithms require a support array.

      More precisely, assuming that x[perm[i]] &le; x[perm[i + 1]], after stabilization we will also have that x[perm[i]] = x[perm[i + 1]] implies perm[i] &le; perm[i + 1].

      Parameters:
      perm - a permutation array indexing x so that it is sorted.
      x - the sorted array to be stabilized.
    • quickSort

      public static void quickSort(float[] x, float[] y, int from, int to)
      Sorts the specified range of elements of two arrays according to the natural lexicographical ascending order using quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      This method implements a lexicographical sorting of the arguments. Pairs of elements in the same position in the two provided arrays will be considered a single key, and permuted accordingly. In the end, either x[i] &lt; x[i + 1] or x[i] == x[i + 1] and y[i] &le; y[i + 1].

      Parameters:
      x - the first array to be sorted.
      y - the second array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • quickSort

      public static void quickSort(float[] x, float[] y)
      Sorts two arrays according to the natural lexicographical ascending order using quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      This method implements a lexicographical sorting of the arguments. Pairs of elements in the same position in the two provided arrays will be considered a single key, and permuted accordingly. In the end, either x[i] &lt; x[i + 1] or x[i] == x[i + 1] and y[i] &le; y[i + 1].

      Parameters:
      x - the first array to be sorted.
      y - the second array to be sorted.
    • parallelQuickSort

      public static void parallelQuickSort(float[] x, float[] y, int from, int to)
      Sorts the specified range of elements of two arrays according to the natural lexicographical ascending order using a parallel quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      This method implements a lexicographical sorting of the arguments. Pairs of elements in the same position in the two provided arrays will be considered a single key, and permuted accordingly. In the end, either x[i] &lt; x[i + 1] or x[i] == x[i + 1] and y[i] &le; y[i + 1].

      Parameters:
      x - the first array to be sorted.
      y - the second array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • parallelQuickSort

      public static void parallelQuickSort(float[] x, float[] y)
      Sorts two arrays according to the natural lexicographical ascending order using a parallel quicksort.

      The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas McIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages 1249−1265, 1993.

      This method implements a lexicographical sorting of the arguments. Pairs of elements in the same position in the two provided arrays will be considered a single key, and permuted accordingly. In the end, either x[i] &lt; x[i + 1] or x[i] == x[i + 1] and y[i] &le; y[i + 1].

      Parameters:
      x - the first array to be sorted.
      y - the second array to be sorted.
    • unstableSort

      public static void unstableSort(float[] a, int from, int to)
      Sorts an array according to the natural ascending order, potentially dynamically choosing an appropriate algorithm given the type and size of the array. The sort will be stable unless it is provable that it would be impossible for there to be any difference between a stable and unstable sort for the given type, in which case stability is meaningless and thus unspecified.
      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      Since:
      8.3.0
    • unstableSort

      public static void unstableSort(float[] a)
      Sorts the specified range of elements according to the natural ascending order potentially dynamically choosing an appropriate algorithm given the type and size of the array. No assurance is made of the stability of the sort.
      Parameters:
      a - the array to be sorted.
      Since:
      8.3.0
    • unstableSort

      public static void unstableSort(float[] a, int from, int to, FloatComparator comp)
      Sorts the specified range of elements according to the order induced by the specified comparator, potentially dynamically choosing an appropriate algorithm given the type and size of the array. No assurance is made of the stability of the sort.
      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      comp - the comparator to determine the sorting order.
      Since:
      8.3.0
    • unstableSort

      public static void unstableSort(float[] a, FloatComparator comp)
      Sorts an array according to the order induced by the specified comparator, potentially dynamically choosing an appropriate algorithm given the type and size of the array. No assurance is made of the stability of the sort.
      Parameters:
      a - the array to be sorted.
      comp - the comparator to determine the sorting order.
      Since:
      8.3.0
    • mergeSort

      public static void mergeSort(float[] a, int from, int to, float[] supp)
      Sorts the specified range of elements according to the natural ascending order using mergesort, using a given pre-filled support array.

      This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. Moreover, no support arrays will be allocated.

      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      supp - a support array containing at least to elements, and whose entries are identical to those of a in the specified range. It can be null, in which case a will be cloned.
    • mergeSort

      public static void mergeSort(float[] a, int from, int to)
      Sorts the specified range of elements according to the natural ascending order using mergesort.

      This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. An array as large as a will be allocated by this method.

      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • mergeSort

      public static void mergeSort(float[] a)
      Sorts an array according to the natural ascending order using mergesort.

      This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. An array as large as a will be allocated by this method.

      Parameters:
      a - the array to be sorted.
    • mergeSort

      public static void mergeSort(float[] a, int from, int to, FloatComparator comp, float[] supp)
      Sorts the specified range of elements according to the order induced by the specified comparator using mergesort, using a given pre-filled support array.

      This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. Moreover, no support arrays will be allocated.

      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      comp - the comparator to determine the sorting order.
      supp - a support array containing at least to elements, and whose entries are identical to those of a in the specified range. It can be null, in which case a will be cloned.
    • mergeSort

      public static void mergeSort(float[] a, int from, int to, FloatComparator comp)
      Sorts the specified range of elements according to the order induced by the specified comparator using mergesort.

      This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. An array as large as a will be allocated by this method.

      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      comp - the comparator to determine the sorting order.
    • mergeSort

      public static void mergeSort(float[] a, FloatComparator comp)
      Sorts an array according to the order induced by the specified comparator using mergesort.

      This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. An array as large as a will be allocated by this method.

      Parameters:
      a - the array to be sorted.
      comp - the comparator to determine the sorting order.
    • stableSort

      public static void stableSort(float[] a, int from, int to)
      Sorts an array according to the natural ascending order, potentially dynamically choosing an appropriate algorithm given the type and size of the array. The sort will be stable unless it is provable that it would be impossible for there to be any difference between a stable and unstable sort for the given type, in which case stability is meaningless and thus unspecified.

      An array as large as a may be allocated by this method.

      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      Since:
      8.3.0
    • stableSort

      public static void stableSort(float[] a)
      Sorts the specified range of elements according to the natural ascending order potentially dynamically choosing an appropriate algorithm given the type and size of the array. The sort will be stable unless it is provable that it would be impossible for there to be any difference between a stable and unstable sort for the given type, in which case stability is meaningless and thus unspecified.

      An array as large as a may be allocated by this method.

      Parameters:
      a - the array to be sorted.
      Since:
      8.3.0
    • stableSort

      public static void stableSort(float[] a, int from, int to, FloatComparator comp)
      Sorts the specified range of elements according to the order induced by the specified comparator, potentially dynamically choosing an appropriate algorithm given the type and size of the array. The sort will be stable unless it is provable that it would be impossible for there to be any difference between a stable and unstable sort for the given type, in which case stability is meaningless and thus unspecified.

      An array as large as a may be allocated by this method.

      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      comp - the comparator to determine the sorting order.
      Since:
      8.3.0
    • stableSort

      public static void stableSort(float[] a, FloatComparator comp)
      Sorts an array according to the order induced by the specified comparator, potentially dynamically choosing an appropriate algorithm given the type and size of the array. The sort will be stable unless it is provable that it would be impossible for there to be any difference between a stable and unstable sort for the given type, in which case stability is meaningless and thus unspecified.

      An array as large as a may be allocated by this method.

      Parameters:
      a - the array to be sorted.
      comp - the comparator to determine the sorting order.
      Since:
      8.3.0
    • binarySearch

      public static int binarySearch(float[] a, int from, int to, float key)
      Searches a range of the specified array for the specified value using the binary search algorithm. The range must be sorted prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.
      Parameters:
      a - the array to be searched.
      from - the index of the first element (inclusive) to be searched.
      to - the index of the last element (exclusive) to be searched.
      key - the value to be searched for.
      Returns:
      index of the search key, if it is contained in the array; otherwise, (-(<i>insertion point</i>) - 1). The insertion point is defined as the the point at which the value would be inserted into the array: the index of the first element greater than the key, or the length of the array, if all elements in the array are less than the specified key. Note that this guarantees that the return value will be ≥ 0 if and only if the key is found.
      See Also:
    • binarySearch

      public static int binarySearch(float[] a, float key)
      Searches an array for the specified value using the binary search algorithm. The range must be sorted prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.
      Parameters:
      a - the array to be searched.
      key - the value to be searched for.
      Returns:
      index of the search key, if it is contained in the array; otherwise, (-(<i>insertion point</i>) - 1). The insertion point is defined as the the point at which the value would be inserted into the array: the index of the first element greater than the key, or the length of the array, if all elements in the array are less than the specified key. Note that this guarantees that the return value will be ≥ 0 if and only if the key is found.
      See Also:
    • binarySearch

      public static int binarySearch(float[] a, int from, int to, float key, FloatComparator c)
      Searches a range of the specified array for the specified value using the binary search algorithm and a specified comparator. The range must be sorted following the comparator prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.
      Parameters:
      a - the array to be searched.
      from - the index of the first element (inclusive) to be searched.
      to - the index of the last element (exclusive) to be searched.
      key - the value to be searched for.
      c - a comparator.
      Returns:
      index of the search key, if it is contained in the array; otherwise, (-(<i>insertion point</i>) - 1). The insertion point is defined as the the point at which the value would be inserted into the array: the index of the first element greater than the key, or the length of the array, if all elements in the array are less than the specified key. Note that this guarantees that the return value will be ≥ 0 if and only if the key is found.
      See Also:
    • binarySearch

      public static int binarySearch(float[] a, float key, FloatComparator c)
      Searches an array for the specified value using the binary search algorithm and a specified comparator. The range must be sorted following the comparator prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.
      Parameters:
      a - the array to be searched.
      key - the value to be searched for.
      c - a comparator.
      Returns:
      index of the search key, if it is contained in the array; otherwise, (-(<i>insertion point</i>) - 1). The insertion point is defined as the the point at which the value would be inserted into the array: the index of the first element greater than the key, or the length of the array, if all elements in the array are less than the specified key. Note that this guarantees that the return value will be ≥ 0 if and only if the key is found.
      See Also:
    • radixSort

      public static void radixSort(float[] a)
      Sorts the specified array using radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      Parameters:
      a - the array to be sorted.
      Implementation Specification:
      This implementation is significantly faster than quicksort already at small sizes (say, more than 5000 elements), but it can only sort in ascending order.
    • radixSort

      public static void radixSort(float[] a, int from, int to)
      Sorts the specified range of an array using radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      Implementation Specification:
      This implementation is significantly faster than quicksort already at small sizes (say, more than 5000 elements), but it can only sort in ascending order.
    • parallelRadixSort

      public static void parallelRadixSort(float[] a, int from, int to)
      Sorts the specified range of an array using parallel radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      Parameters:
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • parallelRadixSort

      public static void parallelRadixSort(float[] a)
      Sorts the specified array using parallel radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      Parameters:
      a - the array to be sorted.
    • radixSortIndirect

      public static void radixSortIndirect(int[] perm, float[] a, boolean stable)
      Sorts the specified array using indirect radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that a[perm[i]] &le; a[perm[i + 1]].

      Parameters:
      perm - a permutation array indexing a.
      a - the array to be sorted.
      stable - whether the sorting algorithm should be stable.
      Implementation Specification:
      This implementation will allocate, in the stable case, a support array as large as perm (note that the stable version is slightly faster).
    • radixSortIndirect

      public static void radixSortIndirect(int[] perm, float[] a, int from, int to, boolean stable)
      Sorts the specified array using indirect radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that a[perm[i]] &le; a[perm[i + 1]].

      Parameters:
      perm - a permutation array indexing a.
      a - the array to be sorted.
      from - the index of the first element of perm (inclusive) to be permuted.
      to - the index of the last element of perm (exclusive) to be permuted.
      stable - whether the sorting algorithm should be stable.
      Implementation Specification:
      This implementation will allocate, in the stable case, a support array as large as perm (note that the stable version is slightly faster).
    • parallelRadixSortIndirect

      public static void parallelRadixSortIndirect(int[] perm, float[] a, int from, int to, boolean stable)
      Sorts the specified range of an array using parallel indirect radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that a[perm[i]] &le; a[perm[i + 1]].

      Parameters:
      perm - a permutation array indexing a.
      a - the array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
      stable - whether the sorting algorithm should be stable.
    • parallelRadixSortIndirect

      public static void parallelRadixSortIndirect(int[] perm, float[] a, boolean stable)
      Sorts the specified array using parallel indirect radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that a[perm[i]] &le; a[perm[i + 1]].

      Parameters:
      perm - a permutation array indexing a.
      a - the array to be sorted.
      stable - whether the sorting algorithm should be stable.
    • radixSort

      public static void radixSort(float[] a, float[] b)
      Sorts the specified pair of arrays lexicographically using radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implements a lexicographical sorting of the arguments. Pairs of elements in the same position in the two provided arrays will be considered a single key, and permuted accordingly. In the end, either a[i] &lt; a[i + 1] or a[i] == a[i + 1] and b[i] &le; b[i + 1].

      Parameters:
      a - the first array to be sorted.
      b - the second array to be sorted.
    • radixSort

      public static void radixSort(float[] a, float[] b, int from, int to)
      Sorts the specified range of elements of two arrays using radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implements a lexicographical sorting of the arguments. Pairs of elements in the same position in the two provided arrays will be considered a single key, and permuted accordingly. In the end, either a[i] &lt; a[i + 1] or a[i] == a[i + 1] and b[i] &le; b[i + 1].

      Parameters:
      a - the first array to be sorted.
      b - the second array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • parallelRadixSort

      public static void parallelRadixSort(float[] a, float[] b, int from, int to)
      Sorts the specified range of elements of two arrays using a parallel radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implements a lexicographical sorting of the arguments. Pairs of elements in the same position in the two provided arrays will be considered a single key, and permuted accordingly. In the end, either a[i] &lt; a[i + 1] or a[i] == a[i + 1] and b[i] &le; b[i + 1].

      Parameters:
      a - the first array to be sorted.
      b - the second array to be sorted.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • parallelRadixSort

      public static void parallelRadixSort(float[] a, float[] b)
      Sorts two arrays using a parallel radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implements a lexicographical sorting of the arguments. Pairs of elements in the same position in the two provided arrays will be considered a single key, and permuted accordingly. In the end, either a[i] &lt; a[i + 1] or a[i] == a[i + 1] and b[i] &le; b[i + 1].

      Parameters:
      a - the first array to be sorted.
      b - the second array to be sorted.
    • radixSortIndirect

      public static void radixSortIndirect(int[] perm, float[] a, float[] b, boolean stable)
      Sorts the specified pair of arrays lexicographically using indirect radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that a[perm[i]] &le; a[perm[i + 1]] or a[perm[i]] == a[perm[i + 1]] and b[perm[i]] &le; b[perm[i + 1]].

      Parameters:
      perm - a permutation array indexing a.
      a - the array to be sorted.
      b - the second array to be sorted.
      stable - whether the sorting algorithm should be stable.
      Implementation Specification:
      This implementation will allocate, in the stable case, a further support array as large as perm (note that the stable version is slightly faster).
    • radixSortIndirect

      public static void radixSortIndirect(int[] perm, float[] a, float[] b, int from, int to, boolean stable)
      Sorts the specified pair of arrays lexicographically using indirect radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implement an indirect sort. The elements of perm (which must be exactly the numbers in the interval [0..perm.length)) will be permuted so that a[perm[i]] &le; a[perm[i + 1]] or a[perm[i]] == a[perm[i + 1]] and b[perm[i]] &le; b[perm[i + 1]].

      Parameters:
      perm - a permutation array indexing a.
      a - the array to be sorted.
      b - the second array to be sorted.
      from - the index of the first element of perm (inclusive) to be permuted.
      to - the index of the last element of perm (exclusive) to be permuted.
      stable - whether the sorting algorithm should be stable.
      Implementation Specification:
      This implementation will allocate, in the stable case, a further support array as large as perm (note that the stable version is slightly faster).
    • radixSort

      public static void radixSort(float[][] a)
      Sorts the specified array of arrays lexicographically using radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implements a lexicographical sorting of the provided arrays. Tuples of elements in the same position will be considered a single key, and permuted accordingly.

      Parameters:
      a - an array containing arrays of equal length to be sorted lexicographically in parallel.
    • radixSort

      public static void radixSort(float[][] a, int from, int to)
      Sorts the specified array of arrays lexicographically using radix sort.

      The sorting algorithm is a tuned radix sort adapted from Peter M. McIlroy, Keith Bostic and M. Douglas McIlroy, “Engineering radix sort”, Computing Systems, 6(1), pages 5−27 (1993).

      This method implements a lexicographical sorting of the provided arrays. Tuples of elements in the same position will be considered a single key, and permuted accordingly.

      Parameters:
      a - an array containing arrays of equal length to be sorted lexicographically in parallel.
      from - the index of the first element (inclusive) to be sorted.
      to - the index of the last element (exclusive) to be sorted.
    • shuffle

      public static float[] shuffle(float[] a, int from, int to, Random random)
      Shuffles the specified array fragment using the specified pseudorandom number generator.
      Parameters:
      a - the array to be shuffled.
      from - the index of the first element (inclusive) to be shuffled.
      to - the index of the last element (exclusive) to be shuffled.
      random - a pseudorandom number generator.
      Returns:
      a.
    • shuffle

      public static float[] shuffle(float[] a, Random random)
      Shuffles the specified array using the specified pseudorandom number generator.
      Parameters:
      a - the array to be shuffled.
      random - a pseudorandom number generator.
      Returns:
      a.
    • reverse

      public static float[] reverse(float[] a)
      Reverses the order of the elements in the specified array.
      Parameters:
      a - the array to be reversed.
      Returns:
      a.
    • reverse

      public static float[] reverse(float[] a, int from, int to)
      Reverses the order of the elements in the specified array fragment.
      Parameters:
      a - the array to be reversed.
      from - the index of the first element (inclusive) to be reversed.
      to - the index of the last element (exclusive) to be reversed.
      Returns:
      a.