Class ArrayUtilities

java.lang.Object
de.gurkenlabs.litiengine.util.ArrayUtilities

public final class ArrayUtilities extends Object
  • Field Details

  • Method Details

    • concat

      public static byte[] concat(byte[] first, byte[] second)
      Concatenates the two specified byte arrays to a new array.
      Parameters:
      first - The first array.
      second - The second array.
      Returns:
      A new array with both specified arrays in sequence.
    • concat

      public static int[] concat(int[] first, int[] second)
      Concatenates the two specified int arrays to a new array.
      Parameters:
      first - The first array.
      second - The second array.
      Returns:
      A new array with both specified arrays in sequence.
    • concat

      public static long[] concat(long[] first, long[] second)
      Concatenates the two specified long arrays to a new array.
      Parameters:
      first - The first array.
      second - The second array.
      Returns:
      A new array with both specified arrays in sequence.
    • concat

      public static double[] concat(double[] first, double[] second)
      Concatenates the two specified double arrays to a new array.
      Parameters:
      first - The first array.
      second - The second array.
      Returns:
      A new array with both specified arrays in sequence.
    • concat

      public static <T> T[] concat(T[] first, T[] second)
      Concatenates the two specified double arrays to a new array.
      Type Parameters:
      T - The type of the array elements.
      Parameters:
      first - The first array.
      second - The second array.
      Returns:
      A new array with both specified arrays in sequence.
    • splitInt

      public static int[] splitInt(String delimiterSeparatedString)
      Splits the specified string by the DEFAULT_STRING_DELIMITER into an int array.
      Parameters:
      delimiterSeparatedString - The string to split.
      Returns:
      An int array with all separated elements of the specified string.
    • splitInt

      public static int[] splitInt(String delimiterSeparatedString, String delimiter)
      Splits the specified string by the defined delimiter into an int array.
      Parameters:
      delimiterSeparatedString - The string to split.
      delimiter - The delimiter by which to split the elements.
      Returns:
      An int array with all separated elements of the specified string.
    • splitDouble

      public static double[] splitDouble(String delimiterSeparatedString)
      Splits the specified string by the DEFAULT_STRING_DELIMITER into a double array.
      Parameters:
      delimiterSeparatedString - The string to split.
      Returns:
      An double array with all separated elements of the specified string.
    • splitDouble

      public static double[] splitDouble(String delimiterSeparatedString, String delimiter)
      Splits the specified string by the defined delimiter into a double array.
      Parameters:
      delimiterSeparatedString - The string to split.
      delimiter - The delimiter by which to split the elements.
      Returns:
      An double array with all separated elements of the specified string.
    • join

      public static String join(boolean[] arr)
      Joins the specified array with the DEFAULT_STRING_DELIMITER.
      Parameters:
      arr - The array that provides the elements to be joined.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(boolean[] arr, String delimiter)
      Joins the specified array with the defined delimiter.
      Parameters:
      arr - The array that provides the elements to be joined.
      delimiter - The delimiter used to separate the elements with.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(int[] arr)
      Joins the specified array with the DEFAULT_STRING_DELIMITER.
      Parameters:
      arr - The array that provides the elements to be joined.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(int[] arr, String delimiter)
      Joins the specified array with the defined delimiter.
      Parameters:
      arr - The array that provides the elements to be joined.
      delimiter - The delimiter used to separate the elements with.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(double[] arr)
      Joins the specified array with the DEFAULT_STRING_DELIMITER.
      Parameters:
      arr - The array that provides the elements to be joined.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(double[] arr, String delimiter)
      Joins the specified array with the defined delimiter.
      Parameters:
      arr - The array that provides the elements to be joined.
      delimiter - The delimiter used to separate the elements with.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(float[] arr)
      Joins the specified array with the DEFAULT_STRING_DELIMITER.
      Parameters:
      arr - The array that provides the elements to be joined.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(float[] arr, String delimiter)
      Joins the specified array with the defined delimiter.
      Parameters:
      arr - The array that provides the elements to be joined.
      delimiter - The delimiter used to separate the elements with.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(short[] arr)
      Joins the specified array with the DEFAULT_STRING_DELIMITER.
      Parameters:
      arr - The array that provides the elements to be joined.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(short[] arr, String delimiter)
    • join

      public static String join(long[] arr)
      Joins the specified array with the DEFAULT_STRING_DELIMITER.
      Parameters:
      arr - The array that provides the elements to be joined.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(long[] arr, String delimiter)
      Joins the specified array with the defined delimiter.
      Parameters:
      arr - The array that provides the elements to be joined.
      delimiter - The delimiter used to separate the elements with.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(byte[] arr)
      Joins the specified array with the DEFAULT_STRING_DELIMITER.
      Parameters:
      arr - The array that provides the elements to be joined.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(byte[] arr, String delimiter)
      Joins the specified array with the defined delimiter.
      Parameters:
      arr - The array that provides the elements to be joined.
      delimiter - The delimiter used to separate the elements with.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(Collection<?> collection)
      Joins the specified list with the DEFAULT_STRING_DELIMITER.
      Parameters:
      collection - The list that provides the elements to be joined.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(Collection<?> collection, String delimiter)
      Joins the specified collection with the defined delimiter.
      Parameters:
      collection - The list that provides the elements to be joined.
      delimiter - The delimiter used to separate the elements with.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(Object[] arr)
      Joins the specified array with the DEFAULT_STRING_DELIMITER.
      Parameters:
      arr - The array that provides the elements to be joined.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • join

      public static String join(Object[] arr, String delimiter)
      Joins the specified array with the defined delimiter.
      Parameters:
      arr - The array that provides the elements to be joined.
      delimiter - The delimiter used to separate the elements with.
      Returns:
      A string with all joined elements, separated by the delimiter.
    • toList

      public static <T> List<T> toList(T[][] arr)
    • contains

      public static boolean contains(Object[] arr, Object value)
      Return true if the array contains the specified value.
      Parameters:
      arr - The array that is tested for the existence of the element.
      value - The element to check for in the array.
      Returns:
      True if the specified element is in the array; otherwise false.
    • contains

      public static boolean contains(String[] arr, String argument, boolean ignoreCase)
      Return true if the array contains the specified string argument.
      Parameters:
      arr - The array that is tested for the existence of the argument.
      argument - The argument to check for in the array.
      ignoreCase - A flag indicating whether the case should be ignored when checking for equality.
      Returns:
      True if the specified argument is in the array; otherwise false.
    • remove

      public static <T> T[] remove(T[] input, T deleteItem)
      Removes the specified deleteItem from the input array and returns a trimmed new array instance without null entries. The resulting array will have a length -1;
      Type Parameters:
      T - The element type of the array.
      Parameters:
      input - The original array
      deleteItem - The item to delete
      Returns:
      A new array with the length input.length - 1.
    • append

      public static <T> T[] append(T[] input, T addItem)
      Adds the specified item to the input array and returns a new array instance with the length of the input array +1.
      Type Parameters:
      T - The element type of the array.
      Parameters:
      input - The original array.
      addItem - The item to add.
      Returns:
      A new array with the item to add appended at the end.
    • distinct

      public static <T> T[] distinct(T[] first, T[] second)
      Combines the two specified arrays by only keeping distinct values.
      Type Parameters:
      T - The element type of the array.
      Parameters:
      first - The first array.
      second - The second array.
      Returns:
      A new array with every distinct value of the specified arrays.
    • arrayCopy

      public static <T> T[] arrayCopy(T[] original)
      Creates a copy of the specified array.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      original - the array to copy
      Returns:
      a new array that is a copy of the original array
    • toIntegerArray

      public static int[] toIntegerArray(List<Integer> intList)
      Converts a list of Integer objects to an array of primitive int values.
      Parameters:
      intList - the list of Integer objects to convert
      Returns:
      an array of primitive int values