Class ArrayUtil

java.lang.Object
de.tomatengames.util.ArrayUtil

public class ArrayUtil extends Object
Provides methods to work with arrays.
Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean[]
    add(boolean[] array, boolean el, int index)
    Copies the array and inserts the specified element at the specified index.
    static byte[]
    add(byte[] array, byte el, int index)
    Copies the array and inserts the specified element at the specified index.
    static char[]
    add(char[] array, char el, int index)
    Copies the array and inserts the specified element at the specified index.
    static double[]
    add(double[] array, double el, int index)
    Copies the array and inserts the specified element at the specified index.
    static float[]
    add(float[] array, float el, int index)
    Copies the array and inserts the specified element at the specified index.
    static int[]
    add(int[] array, int el, int index)
    Copies the array and inserts the specified element at the specified index.
    static long[]
    add(long[] array, long el, int index)
    Copies the array and inserts the specified element at the specified index.
    static short[]
    add(short[] array, short el, int index)
    Copies the array and inserts the specified element at the specified index.
    static <T> T[]
    add(T[] array, T el, int index, IntFunction<T[]> arrayFactory)
    Copies the array and inserts the specified element at the specified index.
    static boolean[]
    addFirst(boolean[] array, boolean el)
    Copies the array and inserts the specified element to the front.
    static byte[]
    addFirst(byte[] array, byte el)
    Copies the array and inserts the specified element to the front.
    static char[]
    addFirst(char[] array, char el)
    Copies the array and inserts the specified element to the front.
    static double[]
    addFirst(double[] array, double el)
    Copies the array and inserts the specified element to the front.
    static float[]
    addFirst(float[] array, float el)
    Copies the array and inserts the specified element to the front.
    static int[]
    addFirst(int[] array, int el)
    Copies the array and inserts the specified element to the front.
    static long[]
    addFirst(long[] array, long el)
    Copies the array and inserts the specified element to the front.
    static short[]
    addFirst(short[] array, short el)
    Copies the array and inserts the specified element to the front.
    static <T> T[]
    addFirst(T[] array, T el, IntFunction<T[]> arrayFactory)
    Copies the array and inserts the specified element to the front.
    static boolean[]
    addLast(boolean[] array, boolean el)
    Copies the array and inserts the specified element at the end.
    static byte[]
    addLast(byte[] array, byte el)
    Copies the array and inserts the specified element at the end.
    static char[]
    addLast(char[] array, char el)
    Copies the array and inserts the specified element at the end.
    static double[]
    addLast(double[] array, double el)
    Copies the array and inserts the specified element at the end.
    static float[]
    addLast(float[] array, float el)
    Copies the array and inserts the specified element at the end.
    static int[]
    addLast(int[] array, int el)
    Copies the array and inserts the specified element at the end.
    static long[]
    addLast(long[] array, long el)
    Copies the array and inserts the specified element at the end.
    static short[]
    addLast(short[] array, short el)
    Copies the array and inserts the specified element at the end.
    static <T> T[]
    addLast(T[] array, T el, IntFunction<T[]> arrayFactory)
    Copies the array and inserts the specified element at the end.
    static boolean[]
    concat(boolean[]... arrays)
    Concatenates all specified arrays.
    static boolean[]
    concat(boolean[] array1, boolean[] array2)
    Concatenates both arrays.
    static byte[]
    concat(byte[]... arrays)
    Concatenates all specified arrays.
    static byte[]
    concat(byte[] array1, byte[] array2)
    Concatenates both arrays.
    static char[]
    concat(char[]... arrays)
    Concatenates all specified arrays.
    static char[]
    concat(char[] array1, char[] array2)
    Concatenates both arrays.
    static double[]
    concat(double[]... arrays)
    Concatenates all specified arrays.
    static double[]
    concat(double[] array1, double[] array2)
    Concatenates both arrays.
    static float[]
    concat(float[]... arrays)
    Concatenates all specified arrays.
    static float[]
    concat(float[] array1, float[] array2)
    Concatenates both arrays.
    static int[]
    concat(int[]... arrays)
    Concatenates all specified arrays.
    static int[]
    concat(int[] array1, int[] array2)
    Concatenates both arrays.
    static long[]
    concat(long[]... arrays)
    Concatenates all specified arrays.
    static long[]
    concat(long[] array1, long[] array2)
    Concatenates both arrays.
    static short[]
    concat(short[]... arrays)
    Concatenates all specified arrays.
    static short[]
    concat(short[] array1, short[] array2)
    Concatenates both arrays.
    static <T> T[]
    concat(IntFunction<T[]> arrayFactory, T[]... arrays)
    Concatenates all specified arrays.
    static <T, C extends Collection<T>>
    C
    concat(Supplier<C> factory, Collection<? extends T>... collections)
    Concatenates the specified collections to a single one.
    static <T> T[]
    concat(T[] array1, T[] array2, IntFunction<T[]> arrayFactory)
    Concatenates both arrays.
    static boolean
    contains(boolean[] array, boolean element)
    Returns if the specified array contains the specified element.
    static boolean
    contains(byte[] array, byte element)
    Returns if the specified array contains the specified element.
    static boolean
    contains(char[] array, char element)
    Returns if the specified array contains the specified element.
    static boolean
    contains(double[] array, double element)
    Returns if the specified array contains the specified element.
    static boolean
    contains(float[] array, float element)
    Returns if the specified array contains the specified element.
    static boolean
    contains(int[] array, int element)
    Returns if the specified array contains the specified element.
    static boolean
    contains(long[] array, long element)
    Returns if the specified array contains the specified element.
    static boolean
    contains(short[] array, short element)
    Returns if the specified array contains the specified element.
    static <T> boolean
    contains(T[] array, T element)
    Returns if the specified array contains the specified element.
    static <T> boolean
    containsEqual(T[] array, T element)
    Returns if the specified array contains an element that is equal to the specified element.
    static int
    indexOf(boolean[] array, boolean element)
    Returns the first index of the specified element in the array.
    static int
    indexOf(boolean[] array, boolean element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies.
    static int
    indexOf(byte[] array, byte element)
    Returns the first index of the specified element in the array.
    static int
    indexOf(byte[] array, byte element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies.
    static int
    indexOf(char[] array, char element)
    Returns the first index of the specified element in the array.
    static int
    indexOf(char[] array, char element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies.
    static int
    indexOf(double[] array, double element)
    Returns the first index of the specified element in the array.
    static int
    indexOf(double[] array, double element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies.
    static int
    indexOf(float[] array, float element)
    Returns the first index of the specified element in the array.
    static int
    indexOf(float[] array, float element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies.
    static int
    indexOf(int[] array, int element)
    Returns the first index of the specified element in the array.
    static int
    indexOf(int[] array, int element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies.
    static int
    indexOf(long[] array, long element)
    Returns the first index of the specified element in the array.
    static int
    indexOf(long[] array, long element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies.
    static int
    indexOf(short[] array, short element)
    Returns the first index of the specified element in the array.
    static int
    indexOf(short[] array, short element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies.
    static <T> int
    indexOf(T[] array, T element)
    Returns the first index of the specified element in the array.
    static <T> int
    indexOf(T[] array, T element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies.
    static <T> int
    indexOfEqual(T[] array, T element)
    Returns the first index of an element in the array that is equal to the specified element.
    static <T> int
    indexOfEqual(T[] array, T element, int startIndex)
    Returns the first index that is greater than or equal to the startIndex for which array[index] equals element applies.
    static boolean
    isEqualCT(byte[] expected, byte[] actual)
    Performs a near-constant-time comparison for the specified arrays.
    static boolean
    isEqualCT(char[] expected, char[] actual)
    Performs a near-constant-time comparison for the specified arrays.
    static boolean
    isEqualCT(int[] expected, int[] actual)
    Performs a near-constant-time comparison for the specified arrays.
    static boolean
    isEqualCT(long[] expected, long[] actual)
    Performs a near-constant-time comparison for the specified arrays.
    static boolean
    isEqualCT(short[] expected, short[] actual)
    Performs a near-constant-time comparison for the specified arrays.
    static int
    lastIndexOf(boolean[] array, boolean element)
    Returns the last index of the specified element in the array.
    static int
    lastIndexOf(boolean[] array, boolean element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies.
    static int
    lastIndexOf(byte[] array, byte element)
    Returns the last index of the specified element in the array.
    static int
    lastIndexOf(byte[] array, byte element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies.
    static int
    lastIndexOf(char[] array, char element)
    Returns the last index of the specified element in the array.
    static int
    lastIndexOf(char[] array, char element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies.
    static int
    lastIndexOf(double[] array, double element)
    Returns the last index of the specified element in the array.
    static int
    lastIndexOf(double[] array, double element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies.
    static int
    lastIndexOf(float[] array, float element)
    Returns the last index of the specified element in the array.
    static int
    lastIndexOf(float[] array, float element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies.
    static int
    lastIndexOf(int[] array, int element)
    Returns the last index of the specified element in the array.
    static int
    lastIndexOf(int[] array, int element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies.
    static int
    lastIndexOf(long[] array, long element)
    Returns the last index of the specified element in the array.
    static int
    lastIndexOf(long[] array, long element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies.
    static int
    lastIndexOf(short[] array, short element)
    Returns the last index of the specified element in the array.
    static int
    lastIndexOf(short[] array, short element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies.
    static <T> int
    lastIndexOf(T[] array, T element)
    Returns the last index of the specified element in the array.
    static <T> int
    lastIndexOf(T[] array, T element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies.
    static <T> int
    lastIndexOfEqual(T[] array, T element)
    Returns the last index of an element in the array that is equal to the specified element.
    static <T> int
    lastIndexOfEqual(T[] array, T element, int startIndex)
    Returns the last index in the array that is less than or equal to the startIndex for which array[index] equals element applies.
    static boolean[]
    remove(boolean[] array, boolean el)
    Copies the array, but skips the first appearance of the specified element.
    static byte[]
    remove(byte[] array, byte el)
    Copies the array, but skips the first appearance of the specified element.
    static char[]
    remove(char[] array, char el)
    Copies the array, but skips the first appearance of the specified element.
    static double[]
    remove(double[] array, double el)
    Copies the array, but skips the first appearance of the specified element.
    static float[]
    remove(float[] array, float el)
    Copies the array, but skips the first appearance of the specified element.
    static int[]
    remove(int[] array, int el)
    Copies the array, but skips the first appearance of the specified element.
    static long[]
    remove(long[] array, long el)
    Copies the array, but skips the first appearance of the specified element.
    static short[]
    remove(short[] array, short el)
    Copies the array, but skips the first appearance of the specified element.
    static <T> T[]
    remove(T[] array, T el, IntFunction<T[]> arrayFactory)
    Copies the array, but skips the first appearance of the specified element.
    static <T> T[]
    removeEqual(T[] array, T el, IntFunction<T[]> arrayFactory)
    Copies the array, but skips the first appearance an element that is equal to the specified element.
    static boolean[]
    removeIndex(boolean[] array, int index)
    Copies the array, but skips the specified index.
    static byte[]
    removeIndex(byte[] array, int index)
    Copies the array, but skips the specified index.
    static char[]
    removeIndex(char[] array, int index)
    Copies the array, but skips the specified index.
    static double[]
    removeIndex(double[] array, int index)
    Copies the array, but skips the specified index.
    static float[]
    removeIndex(float[] array, int index)
    Copies the array, but skips the specified index.
    static int[]
    removeIndex(int[] array, int index)
    Copies the array, but skips the specified index.
    static long[]
    removeIndex(long[] array, int index)
    Copies the array, but skips the specified index.
    static short[]
    removeIndex(short[] array, int index)
    Copies the array, but skips the specified index.
    static <T> T[]
    removeIndex(T[] array, int index, IntFunction<T[]> arrayFactory)
    Copies the array, but skips the specified index.
    static boolean[]
    reverse(boolean[] array)
    Reverses the specified array inplace.
    static byte[]
    reverse(byte[] array)
    Reverses the specified array inplace.
    static char[]
    reverse(char[] array)
    Reverses the specified array inplace.
    static double[]
    reverse(double[] array)
    Reverses the specified array inplace.
    static float[]
    reverse(float[] array)
    Reverses the specified array inplace.
    static int[]
    reverse(int[] array)
    Reverses the specified array inplace.
    static long[]
    reverse(long[] array)
    Reverses the specified array inplace.
    static short[]
    reverse(short[] array)
    Reverses the specified array inplace.
    static <T> T[]
    reverse(T[] array)
    Reverses the specified array inplace.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • indexOfEqual

      public static <T> int indexOfEqual(T[] array, T element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] equals element applies. If the array is null, it does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOfEqual

      public static <T> int indexOfEqual(T[] array, T element)
      Returns the first index of an element in the array that is equal to the specified element. If the array is null, it does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOfEqual

      public static <T> int lastIndexOfEqual(T[] array, T element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] equals element applies. If the array is null, it does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOfEqual

      public static <T> int lastIndexOfEqual(T[] array, T element)
      Returns the last index of an element in the array that is equal to the specified element. If the array is null, it does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • containsEqual

      public static <T> boolean containsEqual(T[] array, T element)
      Returns if the specified array contains an element that is equal to the specified element. The array null does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      Returns:
      If the array contains the specified element.
    • indexOf

      public static <T> int indexOf(T[] array, T element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOf

      public static <T> int indexOf(T[] array, T element)
      Returns the first index of the specified element in the array. If the array is null, it does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOf

      public static <T> int lastIndexOf(T[] array, T element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOf

      public static <T> int lastIndexOf(T[] array, T element)
      Returns the last index of the specified element in the array. If the array is null, it does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • contains

      public static <T> boolean contains(T[] array, T element)
      Returns if the specified array contains the specified element. The array null does not contain any elements.
      Type Parameters:
      T - The type of the elements.
      Parameters:
      array - The array. May be null.
      element - The element. May be null.
      Returns:
      If the array contains the specified element.
    • indexOf

      public static int indexOf(int[] array, int element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOf

      public static int indexOf(int[] array, int element)
      Returns the first index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(int[] array, int element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(int[] array, int element)
      Returns the last index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • contains

      public static boolean contains(int[] array, int element)
      Returns if the specified array contains the specified element. The array null does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      If the array contains the specified element.
    • indexOf

      public static int indexOf(long[] array, long element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOf

      public static int indexOf(long[] array, long element)
      Returns the first index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(long[] array, long element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(long[] array, long element)
      Returns the last index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • contains

      public static boolean contains(long[] array, long element)
      Returns if the specified array contains the specified element. The array null does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      If the array contains the specified element.
    • indexOf

      public static int indexOf(byte[] array, byte element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOf

      public static int indexOf(byte[] array, byte element)
      Returns the first index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(byte[] array, byte element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(byte[] array, byte element)
      Returns the last index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • contains

      public static boolean contains(byte[] array, byte element)
      Returns if the specified array contains the specified element. The array null does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      If the array contains the specified element.
    • indexOf

      public static int indexOf(short[] array, short element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOf

      public static int indexOf(short[] array, short element)
      Returns the first index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(short[] array, short element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(short[] array, short element)
      Returns the last index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • contains

      public static boolean contains(short[] array, short element)
      Returns if the specified array contains the specified element. The array null does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      If the array contains the specified element.
    • indexOf

      public static int indexOf(char[] array, char element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOf

      public static int indexOf(char[] array, char element)
      Returns the first index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(char[] array, char element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(char[] array, char element)
      Returns the last index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • contains

      public static boolean contains(char[] array, char element)
      Returns if the specified array contains the specified element. The array null does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      If the array contains the specified element.
    • indexOf

      public static int indexOf(float[] array, float element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOf

      public static int indexOf(float[] array, float element)
      Returns the first index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(float[] array, float element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(float[] array, float element)
      Returns the last index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • contains

      public static boolean contains(float[] array, float element)
      Returns if the specified array contains the specified element. The array null does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      If the array contains the specified element.
    • indexOf

      public static int indexOf(double[] array, double element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOf

      public static int indexOf(double[] array, double element)
      Returns the first index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(double[] array, double element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(double[] array, double element)
      Returns the last index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • contains

      public static boolean contains(double[] array, double element)
      Returns if the specified array contains the specified element. The array null does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      If the array contains the specified element.
    • indexOf

      public static int indexOf(boolean[] array, boolean element, int startIndex)
      Returns the first index that is greater than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The first index of the specified element ≥ startIndex. If no such index exists, -1 is returned.
    • indexOf

      public static int indexOf(boolean[] array, boolean element)
      Returns the first index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The first index of the specified element. If the array does not contain the specified element, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(boolean[] array, boolean element, int startIndex)
      Returns the last index in the array that is less than or equal to the startIndex for which array[index] == element applies. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      startIndex - The index where to start the search.
      Returns:
      The last index of the specified element ≤ startIndex. If no such index exists, -1 is returned.
    • lastIndexOf

      public static int lastIndexOf(boolean[] array, boolean element)
      Returns the last index of the specified element in the array. If the array is null, it does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      The last index of the specified element. If the array does not contain the element, -1 is returned.
    • contains

      public static boolean contains(boolean[] array, boolean element)
      Returns if the specified array contains the specified element. The array null does not contain any elements.
      Parameters:
      array - The array. May be null.
      element - The element.
      Returns:
      If the array contains the specified element.
    • concat

      public static <T> T[] concat(T[] array1, T[] array2, IntFunction<T[]> arrayFactory)
      Concatenates both arrays. If an array is null, it is handled like an empty array.

      All elements from array1 are before all from array2. The order of the elements is preserved.

      Type Parameters:
      T - The type of the array elements.
      Parameters:
      array1 - The first array. May be null.
      array2 - The second array. May be null.
      arrayFactory - A factory that should create new arrays of the type T. Should be implemented like T[]::new.
      Returns:
      An array that contains all elements from both specified arrays. The returned array is always created using the array factory. The returned array is not null.
      Throws:
      NullPointerException - If the array factory is null or creates an array null.
      ArrayStoreException - If the array factory does not create a T[] and a type mismatch occurs.
    • concat

      @SafeVarargs public static <T> T[] concat(IntFunction<T[]> arrayFactory, T[]... arrays)
      Concatenates all specified arrays. If an array is null, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.
      Type Parameters:
      T - The type of the array elements.
      Parameters:
      arrayFactory - A factory that should create new arrays of the type T. Should be implemented like T[]::new.
      arrays - The arrays that should be concatenated. Must not be null, but the arrays inside may be null.
      Returns:
      An array that contains all elements from all specified arrays.
      Throws:
      NullPointerException - If the array factory is null or creates an array null.
      ArrayStoreException - If the array factory does not create a T[] and a type mismatch occurs.
    • concat

      @SafeVarargs public static <T, C extends Collection<T>> C concat(Supplier<C> factory, Collection<? extends T>... collections)
      Concatenates the specified collections to a single one. The type of the resulting collection is specified by the factory.
      Type Parameters:
      T - The element type.
      C - The type of the resulting collection. Must not be null.
      Parameters:
      factory - The factory that produces an empty collection.
      collections - The collections that should be concatenated. Must not be null, but the inner collections may be null.
      Returns:
      A collection that contains all elements of the specified collections. The resulting collection is created using the factory. If the factory does not return null, the result is not null.
    • concat

      public static int[] concat(int[] array1, int[] array2)
      Concatenates both arrays. If an array is null, it is handled like an empty array.

      All elements from array1 are before all from array2. The order of the elements is preserved.

      Parameters:
      array1 - The first array. May be null.
      array2 - The second array. May be null.
      Returns:
      An array that contains all elements from both specified arrays. Not null. A new array is created.
    • concat

      public static int[] concat(int[]... arrays)
      Concatenates all specified arrays. If an array is null, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.
      Parameters:
      arrays - The arrays that should be concatenated. Must not be null, but the arrays inside may be null.
      Returns:
      An array that contains all elements from all specified arrays. Not null. A new array is created.
    • concat

      public static long[] concat(long[] array1, long[] array2)
      Concatenates both arrays. If an array is null, it is handled like an empty array.

      All elements from array1 are before all from array2. The order of the elements is preserved.

      Parameters:
      array1 - The first array. May be null.
      array2 - The second array. May be null.
      Returns:
      An array that contains all elements from both specified arrays. Not null. A new array is created.
    • concat

      public static long[] concat(long[]... arrays)
      Concatenates all specified arrays. If an array is null, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.
      Parameters:
      arrays - The arrays that should be concatenated. Must not be null, but the arrays inside may be null.
      Returns:
      An array that contains all elements from all specified arrays. Not null. A new array is created.
    • concat

      public static byte[] concat(byte[] array1, byte[] array2)
      Concatenates both arrays. If an array is null, it is handled like an empty array.

      All elements from array1 are before all from array2. The order of the elements is preserved.

      Parameters:
      array1 - The first array. May be null.
      array2 - The second array. May be null.
      Returns:
      An array that contains all elements from both specified arrays. Not null. A new array is created.
    • concat

      public static byte[] concat(byte[]... arrays)
      Concatenates all specified arrays. If an array is null, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.
      Parameters:
      arrays - The arrays that should be concatenated. Must not be null, but the arrays inside may be null.
      Returns:
      An array that contains all elements from all specified arrays. Not null. A new array is created.
    • concat

      public static short[] concat(short[] array1, short[] array2)
      Concatenates both arrays. If an array is null, it is handled like an empty array.

      All elements from array1 are before all from array2. The order of the elements is preserved.

      Parameters:
      array1 - The first array. May be null.
      array2 - The second array. May be null.
      Returns:
      An array that contains all elements from both specified arrays. Not null. A new array is created.
    • concat

      public static short[] concat(short[]... arrays)
      Concatenates all specified arrays. If an array is null, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.
      Parameters:
      arrays - The arrays that should be concatenated. Must not be null, but the arrays inside may be null.
      Returns:
      An array that contains all elements from all specified arrays. Not null. A new array is created.
    • concat

      public static char[] concat(char[] array1, char[] array2)
      Concatenates both arrays. If an array is null, it is handled like an empty array.

      All elements from array1 are before all from array2. The order of the elements is preserved.

      Parameters:
      array1 - The first array. May be null.
      array2 - The second array. May be null.
      Returns:
      An array that contains all elements from both specified arrays. Not null. A new array is created.
    • concat

      public static char[] concat(char[]... arrays)
      Concatenates all specified arrays. If an array is null, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.
      Parameters:
      arrays - The arrays that should be concatenated. Must not be null, but the arrays inside may be null.
      Returns:
      An array that contains all elements from all specified arrays. Not null. A new array is created.
    • concat

      public static float[] concat(float[] array1, float[] array2)
      Concatenates both arrays. If an array is null, it is handled like an empty array.

      All elements from array1 are before all from array2. The order of the elements is preserved.

      Parameters:
      array1 - The first array. May be null.
      array2 - The second array. May be null.
      Returns:
      An array that contains all elements from both specified arrays. Not null. A new array is created.
    • concat

      public static float[] concat(float[]... arrays)
      Concatenates all specified arrays. If an array is null, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.
      Parameters:
      arrays - The arrays that should be concatenated. Must not be null, but the arrays inside may be null.
      Returns:
      An array that contains all elements from all specified arrays. Not null. A new array is created.
    • concat

      public static double[] concat(double[] array1, double[] array2)
      Concatenates both arrays. If an array is null, it is handled like an empty array.

      All elements from array1 are before all from array2. The order of the elements is preserved.

      Parameters:
      array1 - The first array. May be null.
      array2 - The second array. May be null.
      Returns:
      An array that contains all elements from both specified arrays. Not null. A new array is created.
    • concat

      public static double[] concat(double[]... arrays)
      Concatenates all specified arrays. If an array is null, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.
      Parameters:
      arrays - The arrays that should be concatenated. Must not be null, but the arrays inside may be null.
      Returns:
      An array that contains all elements from all specified arrays. Not null. A new array is created.
    • concat

      public static boolean[] concat(boolean[] array1, boolean[] array2)
      Concatenates both arrays. If an array is null, it is handled like an empty array.

      All elements from array1 are before all from array2. The order of the elements is preserved.

      Parameters:
      array1 - The first array. May be null.
      array2 - The second array. May be null.
      Returns:
      An array that contains all elements from both specified arrays. Not null. A new array is created.
    • concat

      public static boolean[] concat(boolean[]... arrays)
      Concatenates all specified arrays. If an array is null, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.
      Parameters:
      arrays - The arrays that should be concatenated. Must not be null, but the arrays inside may be null.
      Returns:
      An array that contains all elements from all specified arrays. Not null. A new array is created.
    • reverse

      public static <T> T[] reverse(T[] array)
      Reverses the specified array inplace. If the array is null, nothing happens and null is returned.
      Type Parameters:
      T - The element type.
      Parameters:
      array - The array that should be reversed. May be null.
      Returns:
      The specified array for piping.
    • reverse

      public static int[] reverse(int[] array)
      Reverses the specified array inplace. If the array is null, nothing happens and null is returned.
      Parameters:
      array - The array that should be reversed. May be null.
      Returns:
      The specified array for piping.
    • reverse

      public static long[] reverse(long[] array)
      Reverses the specified array inplace. If the array is null, nothing happens and null is returned.
      Parameters:
      array - The array that should be reversed. May be null.
      Returns:
      The specified array for piping.
    • reverse

      public static byte[] reverse(byte[] array)
      Reverses the specified array inplace. If the array is null, nothing happens and null is returned.
      Parameters:
      array - The array that should be reversed. May be null.
      Returns:
      The specified array for piping.
    • reverse

      public static short[] reverse(short[] array)
      Reverses the specified array inplace. If the array is null, nothing happens and null is returned.
      Parameters:
      array - The array that should be reversed. May be null.
      Returns:
      The specified array for piping.
    • reverse

      public static char[] reverse(char[] array)
      Reverses the specified array inplace. If the array is null, nothing happens and null is returned.
      Parameters:
      array - The array that should be reversed. May be null.
      Returns:
      The specified array for piping.
    • reverse

      public static float[] reverse(float[] array)
      Reverses the specified array inplace. If the array is null, nothing happens and null is returned.
      Parameters:
      array - The array that should be reversed. May be null.
      Returns:
      The specified array for piping.
    • reverse

      public static double[] reverse(double[] array)
      Reverses the specified array inplace. If the array is null, nothing happens and null is returned.
      Parameters:
      array - The array that should be reversed. May be null.
      Returns:
      The specified array for piping.
    • reverse

      public static boolean[] reverse(boolean[] array)
      Reverses the specified array inplace. If the array is null, nothing happens and null is returned.
      Parameters:
      array - The array that should be reversed. May be null.
      Returns:
      The specified array for piping.
    • add

      public static <T> T[] add(T[] array, T el, int index, IntFunction<T[]> arrayFactory)
      Copies the array and inserts the specified element at the specified index. If the array is null, it is handled like an empty array.
      Type Parameters:
      T - The element type.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted. May be null.
      index - The index where the element should be inserted. Must not be negative and must not be greater than array.length.
      arrayFactory - A factory that creates arrays of a given size. Should be implemented like T[]::new.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Throws:
      IndexOutOfBoundsException - If the index is negative or greater than the length of the array.
      Since:
      1.1
    • addFirst

      public static <T> T[] addFirst(T[] array, T el, IntFunction<T[]> arrayFactory)
      Copies the array and inserts the specified element to the front. The resulting array is
      [el, array...]
      
      If the array is null, it is handled like an empty array.
      Type Parameters:
      T - The element type.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted. May be null.
      arrayFactory - A factory that creates arrays of a given size. Should be implemented like T[]::new.
      Returns:
      A new array that contains the specified element and all elements from the specified array. Not null.
      Since:
      1.1
    • addLast

      public static <T> T[] addLast(T[] array, T el, IntFunction<T[]> arrayFactory)
      Copies the array and inserts the specified element at the end. The resulting array is
      [array..., el]
      
      If the array is null, it is handled like an empty array.
      Type Parameters:
      T - The element type.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted. May be null.
      arrayFactory - A factory that creates arrays of a given size. Should be implemented like T[]::new.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Since:
      1.1
    • removeIndex

      public static <T> T[] removeIndex(T[] array, int index, IntFunction<T[]> arrayFactory)
      Copies the array, but skips the specified index. The result is an array with one element less. If the array is null, it is handled like an empty array.
      Type Parameters:
      T - The element type.
      Parameters:
      array - The array. May be null.
      index - The index that should be removed. Must be in range.
      arrayFactory - A factory that creates arrays of a given size. Should be implemented like T[]::new.
      Returns:
      A new array without the element at the specified index. Not null.
      Throws:
      IndexOutOfBoundsException - If index < 0 or index >= array.length. Occurs always if the array is empty or null.
      Since:
      1.1
    • remove

      public static <T> T[] remove(T[] array, T el, IntFunction<T[]> arrayFactory)
      Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Type Parameters:
      T - The element type.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed. May be null.
      arrayFactory - A factory that creates arrays of a given size. Should be implemented like T[]::new.
      Returns:
      A new array without the first appearance of the specified element. Might be null if the input array is null.
      Since:
      1.1
    • removeEqual

      public static <T> T[] removeEqual(T[] array, T el, IntFunction<T[]> arrayFactory)
      Copies the array, but skips the first appearance an element that is equal to the specified element. The result is an array with one element less if the array contains such an element. If the array does not contain such an element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Type Parameters:
      T - The element type.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed. May be null.
      arrayFactory - A factory that creates arrays of a given size. Should be implemented like T[]::new.
      Returns:
      A new array without the first appearance of an element that is equal to the specified element. Might be null if the input array is null.
      Since:
      1.1
    • add

      public static int[] add(int[] array, int el, int index)
      Copies the array and inserts the specified element at the specified index. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      index - The index where the element should be inserted. Must not be negative and must not be greater than array.length.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Throws:
      IndexOutOfBoundsException - If the index is negative or greater than the length of the array.
      Since:
      1.1
    • addFirst

      public static int[] addFirst(int[] array, int el)
      Copies the array and inserts the specified element to the front. The resulting array is
      [el, array...]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains the specified element and all elements from the specified array. Not null.
      Since:
      1.1
    • addLast

      public static int[] addLast(int[] array, int el)
      Copies the array and inserts the specified element at the end. The resulting array is
      [array..., el]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Since:
      1.1
    • removeIndex

      public static int[] removeIndex(int[] array, int index)
      Copies the array, but skips the specified index. The result is an array with one element less. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      index - The index that should be removed. Must be in range.
      Returns:
      A new array without the element at the specified index. Not null.
      Throws:
      IndexOutOfBoundsException - If index < 0 or index >= array.length. Occurs always if the array is empty or null.
      Since:
      1.1
    • remove

      public static int[] remove(int[] array, int el)
      Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed.
      Returns:
      A new array without the first appearance of the specified element. Might be null if the input array is null.
      Since:
      1.1
    • add

      public static long[] add(long[] array, long el, int index)
      Copies the array and inserts the specified element at the specified index. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      index - The index where the element should be inserted. Must not be negative and must not be greater than array.length.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Throws:
      IndexOutOfBoundsException - If the index is negative or greater than the length of the array.
      Since:
      1.1
    • addFirst

      public static long[] addFirst(long[] array, long el)
      Copies the array and inserts the specified element to the front. The resulting array is
      [el, array...]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains the specified element and all elements from the specified array. Not null.
      Since:
      1.1
    • addLast

      public static long[] addLast(long[] array, long el)
      Copies the array and inserts the specified element at the end. The resulting array is
      [array..., el]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Since:
      1.1
    • removeIndex

      public static long[] removeIndex(long[] array, int index)
      Copies the array, but skips the specified index. The result is an array with one element less. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      index - The index that should be removed. Must be in range.
      Returns:
      A new array without the element at the specified index. Not null.
      Throws:
      IndexOutOfBoundsException - If index < 0 or index >= array.length. Occurs always if the array is empty or null.
      Since:
      1.1
    • remove

      public static long[] remove(long[] array, long el)
      Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed.
      Returns:
      A new array without the first appearance of the specified element. Might be null if the input array is null.
      Since:
      1.1
    • add

      public static byte[] add(byte[] array, byte el, int index)
      Copies the array and inserts the specified element at the specified index. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      index - The index where the element should be inserted. Must not be negative and must not be greater than array.length.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Throws:
      IndexOutOfBoundsException - If the index is negative or greater than the length of the array.
      Since:
      1.1
    • addFirst

      public static byte[] addFirst(byte[] array, byte el)
      Copies the array and inserts the specified element to the front. The resulting array is
      [el, array...]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains the specified element and all elements from the specified array. Not null.
      Since:
      1.1
    • addLast

      public static byte[] addLast(byte[] array, byte el)
      Copies the array and inserts the specified element at the end. The resulting array is
      [array..., el]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Since:
      1.1
    • removeIndex

      public static byte[] removeIndex(byte[] array, int index)
      Copies the array, but skips the specified index. The result is an array with one element less. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      index - The index that should be removed. Must be in range.
      Returns:
      A new array without the element at the specified index. Not null.
      Throws:
      IndexOutOfBoundsException - If index < 0 or index >= array.length. Occurs always if the array is empty or null.
      Since:
      1.1
    • remove

      public static byte[] remove(byte[] array, byte el)
      Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed.
      Returns:
      A new array without the first appearance of the specified element. Might be null if the input array is null.
      Since:
      1.1
    • add

      public static short[] add(short[] array, short el, int index)
      Copies the array and inserts the specified element at the specified index. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      index - The index where the element should be inserted. Must not be negative and must not be greater than array.length.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Throws:
      IndexOutOfBoundsException - If the index is negative or greater than the length of the array.
      Since:
      1.1
    • addFirst

      public static short[] addFirst(short[] array, short el)
      Copies the array and inserts the specified element to the front. The resulting array is
      [el, array...]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains the specified element and all elements from the specified array. Not null.
      Since:
      1.1
    • addLast

      public static short[] addLast(short[] array, short el)
      Copies the array and inserts the specified element at the end. The resulting array is
      [array..., el]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Since:
      1.1
    • removeIndex

      public static short[] removeIndex(short[] array, int index)
      Copies the array, but skips the specified index. The result is an array with one element less. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      index - The index that should be removed. Must be in range.
      Returns:
      A new array without the element at the specified index. Not null.
      Throws:
      IndexOutOfBoundsException - If index < 0 or index >= array.length. Occurs always if the array is empty or null.
      Since:
      1.1
    • remove

      public static short[] remove(short[] array, short el)
      Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed.
      Returns:
      A new array without the first appearance of the specified element. Might be null if the input array is null.
      Since:
      1.1
    • add

      public static char[] add(char[] array, char el, int index)
      Copies the array and inserts the specified element at the specified index. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      index - The index where the element should be inserted. Must not be negative and must not be greater than array.length.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Throws:
      IndexOutOfBoundsException - If the index is negative or greater than the length of the array.
      Since:
      1.1
    • addFirst

      public static char[] addFirst(char[] array, char el)
      Copies the array and inserts the specified element to the front. The resulting array is
      [el, array...]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains the specified element and all elements from the specified array. Not null.
      Since:
      1.1
    • addLast

      public static char[] addLast(char[] array, char el)
      Copies the array and inserts the specified element at the end. The resulting array is
      [array..., el]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Since:
      1.1
    • removeIndex

      public static char[] removeIndex(char[] array, int index)
      Copies the array, but skips the specified index. The result is an array with one element less. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      index - The index that should be removed. Must be in range.
      Returns:
      A new array without the element at the specified index. Not null.
      Throws:
      IndexOutOfBoundsException - If index < 0 or index >= array.length. Occurs always if the array is empty or null.
      Since:
      1.1
    • remove

      public static char[] remove(char[] array, char el)
      Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed.
      Returns:
      A new array without the first appearance of the specified element. Might be null if the input array is null.
      Since:
      1.1
    • add

      public static float[] add(float[] array, float el, int index)
      Copies the array and inserts the specified element at the specified index. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      index - The index where the element should be inserted. Must not be negative and must not be greater than array.length.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Throws:
      IndexOutOfBoundsException - If the index is negative or greater than the length of the array.
      Since:
      1.1
    • addFirst

      public static float[] addFirst(float[] array, float el)
      Copies the array and inserts the specified element to the front. The resulting array is
      [el, array...]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains the specified element and all elements from the specified array. Not null.
      Since:
      1.1
    • addLast

      public static float[] addLast(float[] array, float el)
      Copies the array and inserts the specified element at the end. The resulting array is
      [array..., el]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Since:
      1.1
    • removeIndex

      public static float[] removeIndex(float[] array, int index)
      Copies the array, but skips the specified index. The result is an array with one element less. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      index - The index that should be removed. Must be in range.
      Returns:
      A new array without the element at the specified index. Not null.
      Throws:
      IndexOutOfBoundsException - If index < 0 or index >= array.length. Occurs always if the array is empty or null.
      Since:
      1.1
    • remove

      public static float[] remove(float[] array, float el)
      Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed.
      Returns:
      A new array without the first appearance of the specified element. Might be null if the input array is null.
      Since:
      1.1
    • add

      public static double[] add(double[] array, double el, int index)
      Copies the array and inserts the specified element at the specified index. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      index - The index where the element should be inserted. Must not be negative and must not be greater than array.length.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Throws:
      IndexOutOfBoundsException - If the index is negative or greater than the length of the array.
      Since:
      1.1
    • addFirst

      public static double[] addFirst(double[] array, double el)
      Copies the array and inserts the specified element to the front. The resulting array is
      [el, array...]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains the specified element and all elements from the specified array. Not null.
      Since:
      1.1
    • addLast

      public static double[] addLast(double[] array, double el)
      Copies the array and inserts the specified element at the end. The resulting array is
      [array..., el]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Since:
      1.1
    • removeIndex

      public static double[] removeIndex(double[] array, int index)
      Copies the array, but skips the specified index. The result is an array with one element less. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      index - The index that should be removed. Must be in range.
      Returns:
      A new array without the element at the specified index. Not null.
      Throws:
      IndexOutOfBoundsException - If index < 0 or index >= array.length. Occurs always if the array is empty or null.
      Since:
      1.1
    • remove

      public static double[] remove(double[] array, double el)
      Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed.
      Returns:
      A new array without the first appearance of the specified element. Might be null if the input array is null.
      Since:
      1.1
    • add

      public static boolean[] add(boolean[] array, boolean el, int index)
      Copies the array and inserts the specified element at the specified index. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      index - The index where the element should be inserted. Must not be negative and must not be greater than array.length.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Throws:
      IndexOutOfBoundsException - If the index is negative or greater than the length of the array.
      Since:
      1.1
    • addFirst

      public static boolean[] addFirst(boolean[] array, boolean el)
      Copies the array and inserts the specified element to the front. The resulting array is
      [el, array...]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains the specified element and all elements from the specified array. Not null.
      Since:
      1.1
    • addLast

      public static boolean[] addLast(boolean[] array, boolean el)
      Copies the array and inserts the specified element at the end. The resulting array is
      [array..., el]
      
      If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be inserted.
      Returns:
      A new array that contains all elements from the specified array and the specified element. Not null.
      Since:
      1.1
    • removeIndex

      public static boolean[] removeIndex(boolean[] array, int index)
      Copies the array, but skips the specified index. The result is an array with one element less. If the array is null, it is handled like an empty array.
      Parameters:
      array - The array. May be null.
      index - The index that should be removed. Must be in range.
      Returns:
      A new array without the element at the specified index. Not null.
      Throws:
      IndexOutOfBoundsException - If index < 0 or index >= array.length. Occurs always if the array is empty or null.
      Since:
      1.1
    • remove

      public static boolean[] remove(boolean[] array, boolean el)
      Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array is null, it is handled as an empty array.
      Parameters:
      array - The array. May be null.
      el - The element that should be removed.
      Returns:
      A new array without the first appearance of the specified element. Might be null if the input array is null.
      Since:
      1.1
    • isEqualCT

      public static boolean isEqualCT(int[] expected, int[] actual)
      Performs a near-constant-time comparison for the specified arrays.

      The calculation time depends mostly on the length of actual. In some situations it may depend slightly on the length of expected. It does not depend on the contents of both arrays.

      Parameters:
      expected - The expected array. Not null.
      actual - The array that should be tested to match the expected array. Not null.
      Returns:
      If both arrays are equal.
      Since:
      1.4
    • isEqualCT

      public static boolean isEqualCT(long[] expected, long[] actual)
      Performs a near-constant-time comparison for the specified arrays.

      The calculation time depends mostly on the length of actual. In some situations it may depend slightly on the length of expected. It does not depend on the contents of both arrays.

      Parameters:
      expected - The expected array. Not null.
      actual - The array that should be tested to match the expected array. Not null.
      Returns:
      If both arrays are equal.
      Since:
      1.4
    • isEqualCT

      public static boolean isEqualCT(byte[] expected, byte[] actual)
      Performs a near-constant-time comparison for the specified arrays.

      The calculation time depends mostly on the length of actual. In some situations it may depend slightly on the length of expected. It does not depend on the contents of both arrays.

      Parameters:
      expected - The expected array. Not null.
      actual - The array that should be tested to match the expected array. Not null.
      Returns:
      If both arrays are equal.
      Since:
      1.4
    • isEqualCT

      public static boolean isEqualCT(char[] expected, char[] actual)
      Performs a near-constant-time comparison for the specified arrays.

      The calculation time depends mostly on the length of actual. In some situations it may depend slightly on the length of expected. It does not depend on the contents of both arrays.

      Parameters:
      expected - The expected array. Not null.
      actual - The array that should be tested to match the expected array. Not null.
      Returns:
      If both arrays are equal.
      Since:
      1.4
    • isEqualCT

      public static boolean isEqualCT(short[] expected, short[] actual)
      Performs a near-constant-time comparison for the specified arrays.

      The calculation time depends mostly on the length of actual. In some situations it may depend slightly on the length of expected. It does not depend on the contents of both arrays.

      Parameters:
      expected - The expected array. Not null.
      actual - The array that should be tested to match the expected array. Not null.
      Returns:
      If both arrays are equal.
      Since:
      1.4