Package proguard.util

Class ArrayUtil

java.lang.Object
proguard.util.ArrayUtil

public class ArrayUtil extends Object
This class contains utility methods operating on arrays.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    add(byte[] array, int size, byte element)
    Adds the given element to the given array.
    static char[]
    add(char[] array, int size, char element)
    Adds the given element to the given array.
    static double[]
    add(double[] array, int size, double element)
    Adds the given element to the given array.
    static float[]
    add(float[] array, int size, float element)
    Adds the given element to the given array.
    static int[]
    add(int[] array, int size, int element)
    Adds the given element to the given array.
    static long[]
    add(long[] array, int size, long element)
    Adds the given element to the given array.
    static short[]
    add(short[] array, int size, short element)
    Adds the given element to the given array.
    static <T> T[]
    add(T[] array, int size, T element)
    Adds the given element to the given array.
    static <T> T[]
    cloneOrNull(T[] array)
    Returns a shallow copy of the given array, or null if the input is null.
    static int
    compare(boolean[] array1, int size1, boolean[] array2, int size2)
    Compares the elements of the two given arrays.
    static int
    compare(byte[] array1, int size1, byte[] array2, int size2)
    Compares the elements of the two given arrays.
    static int
    compare(char[] array1, int size1, char[] array2, int size2)
    Compares the elements of the two given arrays.
    static int
    compare(double[] array1, int size1, double[] array2, int size2)
    Compares the elements of the two given arrays.
    static int
    compare(float[] array1, int size1, float[] array2, int size2)
    Compares the elements of the two given arrays.
    static int
    compare(int[] array1, int size1, int[] array2, int size2)
    Compares the elements of the two given arrays.
    static int
    compare(long[] array1, int size1, long[] array2, int size2)
    Compares the elements of the two given arrays.
    static int
    compare(short[] array1, int size1, short[] array2, int size2)
    Compares the elements of the two given arrays.
    static int
    compare(Comparable[] array1, int size1, Comparable[] array2, int size2)
    Compares the elements of the two given arrays.
    static <T> T[]
    concat(T[] first, T[] second)
    Concatenates two arrays into a single one.
    static boolean[]
    ensureArraySize(boolean[] array, int size, boolean initialValue)
    Ensures the given array has a given size.
    static byte[]
    ensureArraySize(byte[] array, int size, byte initialValue)
    Ensures the given array has a given size.
    static char[]
    ensureArraySize(char[] array, int size, char initialValue)
    Ensures the given array has a given size.
    static double[]
    ensureArraySize(double[] array, int size, double initialValue)
    Ensures the given array has a given size.
    static float[]
    ensureArraySize(float[] array, int size, float initialValue)
    Ensures the given array has a given size.
    static int[]
    ensureArraySize(int[] array, int size, int initialValue)
    Ensures the given array has a given size.
    static long[]
    ensureArraySize(long[] array, int size, long initialValue)
    Ensures the given array has a given size.
    static short[]
    ensureArraySize(short[] array, int size, short initialValue)
    Ensures the given array has a given size.
    static <T> T[]
    ensureArraySize(T[] array, int size, T initialValue)
    Ensures the given array has a given size.
    static boolean
    equal(boolean[] array1, boolean[] array2, int size)
    Returns whether the elements of the two given arrays are the same.
    static boolean
    equal(byte[] array1, byte[] array2, int size)
    Returns whether the elements of the two given arrays are the same.
    static boolean
    equal(char[] array1, char[] array2, int size)
    Returns whether the elements of the two given arrays are the same.
    static boolean
    equal(double[] array1, double[] array2, int size)
    Returns whether the elements of the two given arrays are the same.
    static boolean
    equal(float[] array1, float[] array2, int size)
    Returns whether the elements of the two given arrays are the same.
    static boolean
    equal(int[] array1, int[] array2, int size)
    Returns whether the elements of the two given arrays are the same.
    static boolean
    equal(long[] array1, long[] array2, int size)
    Returns whether the elements of the two given arrays are the same.
    static boolean
    equal(short[] array1, short[] array2, int size)
    Returns whether the elements of the two given arrays are the same.
    static boolean
    equal(Object[] array1, Object[] array2, int size)
    Returns whether the elements of the two given arrays are the same.
    static boolean
    equalOrNull(Object[] array1, Object[] array2)
    Returns whether the elements of the two given arrays are the same, or both arrays are null.
    static boolean
    equalOrNull(Object[] array1, Object[] array2, int size)
    Returns whether the elements of the two given arrays are the same, or both arrays are null.
    static boolean[]
    extendArray(boolean[] array, int size)
    Ensures the given array has a given size.
    static byte[]
    extendArray(byte[] array, int size)
    Ensures the given array has a given size.
    static char[]
    extendArray(char[] array, int size)
    Ensures the given array has a given size.
    static double[]
    extendArray(double[] array, int size)
    Ensures the given array has a given size.
    static float[]
    extendArray(float[] array, int size)
    Ensures the given array has a given size.
    static int[]
    extendArray(int[] array, int size)
    Ensures the given array has a given size.
    static long[]
    extendArray(long[] array, int size)
    Ensures the given array has a given size.
    static short[]
    extendArray(short[] array, int size)
    Ensures the given array has a given size.
    static <T> T[]
    extendArray(T[] array, int size)
    Ensures the given array has a given size.
    static int
    hashCode(boolean[] array, int size)
    Returns a hash code for the elements of the given array.
    static int
    hashCode(byte[] array, int size)
    Returns a hash code for the elements of the given array.
    static int
    hashCode(char[] array, int size)
    Returns a hash code for the elements of the given array.
    static int
    hashCode(double[] array, int size)
    Returns a hash code for the elements of the given array.
    static int
    hashCode(float[] array, int size)
    Returns a hash code for the elements of the given array.
    static int
    hashCode(int[] array, int size)
    Returns a hash code for the elements of the given array.
    static int
    hashCode(long[] array, int size)
    Returns a hash code for the elements of the given array.
    static int
    hashCode(short[] array, int size)
    Returns a hash code for the elements of the given array.
    static int
    hashCode(Object[] array, int size)
    Returns a hash code for the elements of the given array.
    static int
    Returns a hash code for the elements of the given array, or 0 if it is null.
    static int
    hashCodeOrNull(Object[] array, int size)
    Returns a hash code for the elements of the given array, or 0 if it is null.
    static int
    indexOf(boolean[] array, int size, boolean value)
    Returns the index of the given value in the given array.
    static int
    indexOf(byte[] array, int size, byte value)
    Returns the index of the given value in the given array.
    static int
    indexOf(char[] array, int size, char value)
    Returns the index of the given value in the given array.
    static int
    indexOf(double[] array, int size, double value)
    Returns the index of the given value in the given array.
    static int
    indexOf(float[] array, int size, float value)
    Returns the index of the given value in the given array.
    static int
    indexOf(int[] array, int size, int value)
    Returns the index of the given value in the given array.
    static int
    indexOf(long[] array, int size, long value)
    Returns the index of the given value in the given array.
    static int
    indexOf(short[] array, int size, short value)
    Returns the index of the given value in the given array.
    static int
    indexOf(Object[] array, int size, Object value)
    Returns the index of the given value in the given array.
    static byte[]
    insert(byte[] array, int size, int index, byte element)
    Inserts the given element in the given array.
    static char[]
    insert(char[] array, int size, int index, char element)
    Inserts the given element in the given array.
    static double[]
    insert(double[] array, int size, int index, double element)
    Inserts the given element in the given array.
    static float[]
    insert(float[] array, int size, int index, float element)
    Inserts the given element in the given array.
    static int[]
    insert(int[] array, int size, int index, int element)
    Inserts the given element in the given array.
    static long[]
    insert(long[] array, int size, int index, long element)
    Inserts the given element in the given array.
    static short[]
    insert(short[] array, int size, int index, short element)
    Inserts the given element in the given array.
    static <T> T[]
    insert(T[] array, int size, int index, T element)
    Inserts the given element in the given array.
    static void
    remove(byte[] array, int size, int index)
    Removes the specified element from the given array.
    static void
    remove(char[] array, int size, int index)
    Removes the specified element from the given array.
    static void
    remove(double[] array, int size, int index)
    Removes the specified element from the given array.
    static void
    remove(float[] array, int size, int index)
    Removes the specified element from the given array.
    static void
    remove(int[] array, int size, int index)
    Removes the specified element from the given array.
    static void
    remove(long[] array, int size, int index)
    Removes the specified element from the given array.
    static void
    remove(short[] array, int size, int index)
    Removes the specified element from the given array.
    static void
    remove(Object[] array, int size, int index)
    Removes the specified element from the given array.

    Methods inherited from class java.lang.Object

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

    • ArrayUtil

      public ArrayUtil()
  • Method Details

    • indexOf

      public static int indexOf(boolean[] array, int size, boolean value)
      Returns the index of the given value in the given array.
      Parameters:
      array - the array.
      size - the size of the array to be checked.
      value - the value to look for.
      Returns:
      the index of the value, or -1 if the value is not present.
    • indexOf

      public static int indexOf(byte[] array, int size, byte value)
      Returns the index of the given value in the given array.
      Parameters:
      array - the array.
      size - the size of the array to be checked.
      value - the value to look for.
      Returns:
      the index of the value, or -1 if the value is not present.
    • indexOf

      public static int indexOf(char[] array, int size, char value)
      Returns the index of the given value in the given array.
      Parameters:
      array - the array.
      size - the size of the array to be checked.
      value - the value to look for.
      Returns:
      the index of the value, or -1 if the value is not present.
    • indexOf

      public static int indexOf(short[] array, int size, short value)
      Returns the index of the given value in the given array.
      Parameters:
      array - the array.
      size - the size of the array to be checked.
      value - the value to look for.
      Returns:
      the index of the value, or -1 if the value is not present.
    • indexOf

      public static int indexOf(int[] array, int size, int value)
      Returns the index of the given value in the given array.
      Parameters:
      array - the array.
      size - the size of the array to be checked.
      value - the value to look for.
      Returns:
      the index of the value, or -1 if the value is not present.
    • indexOf

      public static int indexOf(long[] array, int size, long value)
      Returns the index of the given value in the given array.
      Parameters:
      array - the array.
      size - the size of the array to be checked.
      value - the value to look for.
      Returns:
      the index of the value, or -1 if the value is not present.
    • indexOf

      public static int indexOf(float[] array, int size, float value)
      Returns the index of the given value in the given array.
      Parameters:
      array - the array.
      size - the size of the array to be checked.
      value - the value to look for.
      Returns:
      the index of the value, or -1 if the value is not present.
    • indexOf

      public static int indexOf(double[] array, int size, double value)
      Returns the index of the given value in the given array.
      Parameters:
      array - the array.
      size - the size of the array to be checked.
      value - the value to look for.
      Returns:
      the index of the value, or -1 if the value is not present.
    • indexOf

      public static int indexOf(Object[] array, int size, Object value)
      Returns the index of the given value in the given array.
      Parameters:
      array - the array.
      size - the size of the array to be checked.
      value - the value to look for.
      Returns:
      the index of the value, or -1 if the value is not present.
    • equal

      public static boolean equal(boolean[] array1, boolean[] array2, int size)
      Returns whether the elements of the two given arrays are the same.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • equal

      public static boolean equal(byte[] array1, byte[] array2, int size)
      Returns whether the elements of the two given arrays are the same.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • equal

      public static boolean equal(char[] array1, char[] array2, int size)
      Returns whether the elements of the two given arrays are the same.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • equal

      public static boolean equal(short[] array1, short[] array2, int size)
      Returns whether the elements of the two given arrays are the same.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • equal

      public static boolean equal(int[] array1, int[] array2, int size)
      Returns whether the elements of the two given arrays are the same.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • equal

      public static boolean equal(long[] array1, long[] array2, int size)
      Returns whether the elements of the two given arrays are the same.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • equal

      public static boolean equal(float[] array1, float[] array2, int size)
      Returns whether the elements of the two given arrays are the same.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • equal

      public static boolean equal(double[] array1, double[] array2, int size)
      Returns whether the elements of the two given arrays are the same.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • equal

      public static boolean equal(Object[] array1, Object[] array2, int size)
      Returns whether the elements of the two given arrays are the same.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • equalOrNull

      public static boolean equalOrNull(Object[] array1, Object[] array2)
      Returns whether the elements of the two given arrays are the same, or both arrays are null.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      Returns:
      whether the elements are the same.
    • equalOrNull

      public static boolean equalOrNull(Object[] array1, Object[] array2, int size)
      Returns whether the elements of the two given arrays are the same, or both arrays are null.
      Parameters:
      array1 - the first array.
      array2 - the second array.
      size - the size of the arrays to be checked.
      Returns:
      whether the elements are the same.
    • hashCode

      public static int hashCode(boolean[] array, int size)
      Returns a hash code for the elements of the given array.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • hashCode

      public static int hashCode(byte[] array, int size)
      Returns a hash code for the elements of the given array.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • hashCode

      public static int hashCode(char[] array, int size)
      Returns a hash code for the elements of the given array.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • hashCode

      public static int hashCode(short[] array, int size)
      Returns a hash code for the elements of the given array.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • hashCode

      public static int hashCode(int[] array, int size)
      Returns a hash code for the elements of the given array.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • hashCode

      public static int hashCode(long[] array, int size)
      Returns a hash code for the elements of the given array.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • hashCode

      public static int hashCode(float[] array, int size)
      Returns a hash code for the elements of the given array.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • hashCode

      public static int hashCode(double[] array, int size)
      Returns a hash code for the elements of the given array.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • hashCode

      public static int hashCode(Object[] array, int size)
      Returns a hash code for the elements of the given array.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • hashCodeOrNull

      public static int hashCodeOrNull(Object[] array)
      Returns a hash code for the elements of the given array, or 0 if it is null.
      Parameters:
      array - the array.
      Returns:
      a hash code.
    • hashCodeOrNull

      public static int hashCodeOrNull(Object[] array, int size)
      Returns a hash code for the elements of the given array, or 0 if it is null.
      Parameters:
      array - the array.
      size - the size of the array to be taken into account.
      Returns:
      a hash code.
    • compare

      public static int compare(boolean[] array1, int size1, boolean[] array2, int size2)
      Compares the elements of the two given arrays.
      Parameters:
      array1 - the first array.
      size1 - the size of the first array.
      array2 - the second array.
      size2 - the size of the second array.
      Returns:
      0 if all elements are the same, -1 if the first different element in the first array is smaller than the corresponding element in the second array, or 1 if it is larger.
    • compare

      public static int compare(byte[] array1, int size1, byte[] array2, int size2)
      Compares the elements of the two given arrays.
      Parameters:
      array1 - the first array.
      size1 - the size of the first array.
      array2 - the second array.
      size2 - the size of the second array.
      Returns:
      0 if all elements are the same, -1 if the first different element in the first array is smaller than the corresponding element in the second array, or 1 if it is larger.
    • compare

      public static int compare(char[] array1, int size1, char[] array2, int size2)
      Compares the elements of the two given arrays.
      Parameters:
      array1 - the first array.
      size1 - the size of the first array.
      array2 - the second array.
      size2 - the size of the second array.
      Returns:
      0 if all elements are the same, -1 if the first different element in the first array is smaller than the corresponding element in the second array, or 1 if it is larger.
    • compare

      public static int compare(short[] array1, int size1, short[] array2, int size2)
      Compares the elements of the two given arrays.
      Parameters:
      array1 - the first array.
      size1 - the size of the first array.
      array2 - the second array.
      size2 - the size of the second array.
      Returns:
      0 if all elements are the same, -1 if the first different element in the first array is smaller than the corresponding element in the second array, or 1 if it is larger.
    • compare

      public static int compare(int[] array1, int size1, int[] array2, int size2)
      Compares the elements of the two given arrays.
      Parameters:
      array1 - the first array.
      size1 - the size of the first array.
      array2 - the second array.
      size2 - the size of the second array.
      Returns:
      0 if all elements are the same, -1 if the first different element in the first array is smaller than the corresponding element in the second array, or 1 if it is larger.
    • compare

      public static int compare(long[] array1, int size1, long[] array2, int size2)
      Compares the elements of the two given arrays.
      Parameters:
      array1 - the first array.
      size1 - the size of the first array.
      array2 - the second array.
      size2 - the size of the second array.
      Returns:
      0 if all elements are the same, -1 if the first different element in the first array is smaller than the corresponding element in the second array, or 1 if it is larger.
    • compare

      public static int compare(float[] array1, int size1, float[] array2, int size2)
      Compares the elements of the two given arrays.
      Parameters:
      array1 - the first array.
      size1 - the size of the first array.
      array2 - the second array.
      size2 - the size of the second array.
      Returns:
      0 if all elements are the same, -1 if the first different element in the first array is smaller than the corresponding element in the second array, or 1 if it is larger.
    • compare

      public static int compare(double[] array1, int size1, double[] array2, int size2)
      Compares the elements of the two given arrays.
      Parameters:
      array1 - the first array.
      size1 - the size of the first array.
      array2 - the second array.
      size2 - the size of the second array.
      Returns:
      0 if all elements are the same, -1 if the first different element in the first array is smaller than the corresponding element in the second array, or 1 if it is larger.
    • compare

      public static int compare(Comparable[] array1, int size1, Comparable[] array2, int size2)
      Compares the elements of the two given arrays.
      Parameters:
      array1 - the first array.
      size1 - the size of the first array.
      array2 - the second array.
      size2 - the size of the second array.
      Returns:
      0 if all elements are the same, -1 if the first different element in the first array is smaller than the corresponding element in the second array, or 1 if it is larger.
    • cloneOrNull

      public static <T> T[] cloneOrNull(T[] array)
      Returns a shallow copy of the given array, or null if the input is null.
      Parameters:
      array - the array.
      Returns:
      a shallow copy of the original array, or null if the array is null.
    • extendArray

      public static boolean[] extendArray(boolean[] array, int size)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      Returns:
      the original array, or a copy if it had to be extended.
    • ensureArraySize

      public static boolean[] ensureArraySize(boolean[] array, int size, boolean initialValue)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      initialValue - the initial value of the elements.
      Returns:
      the original array, or a copy if it had to be extended.
    • add

      public static byte[] add(byte[] array, int size, byte element)
      Adds the given element to the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • insert

      public static byte[] insert(byte[] array, int size, int index, byte element)
      Inserts the given element in the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index at which the element is to be added.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • remove

      public static void remove(byte[] array, int size, int index)
      Removes the specified element from the given array.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index of the element to be removed.
    • extendArray

      public static byte[] extendArray(byte[] array, int size)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      Returns:
      the original array, or a copy if it had to be extended.
    • ensureArraySize

      public static byte[] ensureArraySize(byte[] array, int size, byte initialValue)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      initialValue - the initial value of the elements.
      Returns:
      the original array, or a copy if it had to be extended.
    • add

      public static char[] add(char[] array, int size, char element)
      Adds the given element to the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • insert

      public static char[] insert(char[] array, int size, int index, char element)
      Inserts the given element in the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index at which the element is to be added.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • remove

      public static void remove(char[] array, int size, int index)
      Removes the specified element from the given array.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index of the element to be removed.
    • extendArray

      public static char[] extendArray(char[] array, int size)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      Returns:
      the original array, or a copy if it had to be extended.
    • ensureArraySize

      public static char[] ensureArraySize(char[] array, int size, char initialValue)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      initialValue - the initial value of the elements.
      Returns:
      the original array, or a copy if it had to be extended.
    • add

      public static short[] add(short[] array, int size, short element)
      Adds the given element to the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • insert

      public static short[] insert(short[] array, int size, int index, short element)
      Inserts the given element in the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index at which the element is to be added.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • remove

      public static void remove(short[] array, int size, int index)
      Removes the specified element from the given array.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index of the element to be removed.
    • extendArray

      public static short[] extendArray(short[] array, int size)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      Returns:
      the original array, or a copy if it had to be extended.
    • ensureArraySize

      public static short[] ensureArraySize(short[] array, int size, short initialValue)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      initialValue - the initial value of the elements.
      Returns:
      the original array, or a copy if it had to be extended.
    • add

      public static int[] add(int[] array, int size, int element)
      Adds the given element to the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • insert

      public static int[] insert(int[] array, int size, int index, int element)
      Inserts the given element in the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index at which the element is to be added.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • remove

      public static void remove(int[] array, int size, int index)
      Removes the specified element from the given array.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index of the element to be removed.
    • extendArray

      public static int[] extendArray(int[] array, int size)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      Returns:
      the original array, or a copy if it had to be extended.
    • ensureArraySize

      public static int[] ensureArraySize(int[] array, int size, int initialValue)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      initialValue - the initial value of the elements.
      Returns:
      the original array, or a copy if it had to be extended.
    • add

      public static long[] add(long[] array, int size, long element)
      Adds the given element to the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • insert

      public static long[] insert(long[] array, int size, int index, long element)
      Inserts the given element in the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index at which the element is to be added.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • remove

      public static void remove(long[] array, int size, int index)
      Removes the specified element from the given array.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index of the element to be removed.
    • extendArray

      public static long[] extendArray(long[] array, int size)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      Returns:
      the original array, or a copy if it had to be extended.
    • ensureArraySize

      public static long[] ensureArraySize(long[] array, int size, long initialValue)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      initialValue - the initial value of the elements.
      Returns:
      the original array, or a copy if it had to be extended.
    • add

      public static float[] add(float[] array, int size, float element)
      Adds the given element to the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • insert

      public static float[] insert(float[] array, int size, int index, float element)
      Inserts the given element in the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index at which the element is to be added.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • remove

      public static void remove(float[] array, int size, int index)
      Removes the specified element from the given array.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index of the element to be removed.
    • extendArray

      public static float[] extendArray(float[] array, int size)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      Returns:
      the original array, or a copy if it had to be extended.
    • ensureArraySize

      public static float[] ensureArraySize(float[] array, int size, float initialValue)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      initialValue - the initial value of the elements.
      Returns:
      the original array, or a copy if it had to be extended.
    • add

      public static double[] add(double[] array, int size, double element)
      Adds the given element to the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • insert

      public static double[] insert(double[] array, int size, int index, double element)
      Inserts the given element in the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index at which the element is to be added.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • remove

      public static void remove(double[] array, int size, int index)
      Removes the specified element from the given array.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index of the element to be removed.
    • extendArray

      public static double[] extendArray(double[] array, int size)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      Returns:
      the original array, or a copy if it had to be extended.
    • ensureArraySize

      public static double[] ensureArraySize(double[] array, int size, double initialValue)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      initialValue - the initial value of the elements.
      Returns:
      the original array, or a copy if it had to be extended.
    • add

      public static <T> T[] add(T[] array, int size, T element)
      Adds the given element to the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • insert

      public static <T> T[] insert(T[] array, int size, int index, T element)
      Inserts the given element in the given array. The array is extended if necessary.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index at which the element is to be added.
      element - the element to be added.
      Returns:
      the original array, or a copy if it had to be extended.
    • remove

      public static void remove(Object[] array, int size, int index)
      Removes the specified element from the given array.
      Parameters:
      array - the array.
      size - the original size of the array.
      index - the index of the element to be removed.
    • extendArray

      public static <T> T[] extendArray(T[] array, int size)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      Returns:
      the original array, or a copy if it had to be extended.
    • ensureArraySize

      public static <T> T[] ensureArraySize(T[] array, int size, T initialValue)
      Ensures the given array has a given size.
      Parameters:
      array - the array.
      size - the target size of the array.
      initialValue - the initial value of the elements.
      Returns:
      the original array, or a copy if it had to be extended.
    • concat

      public static <T> T[] concat(T[] first, T[] second)
      Concatenates two arrays into a single one.