package de.gurkenlabs.litiengine.util;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;

public final class ArrayUtilities {
  private static final Logger log = Logger.getLogger(ArrayUtilities.class.getName());

  private ArrayUtilities() {
  }

  public static byte[] arrayConcat(final byte[] firstArray, final byte[] secondArray) {
    final int aLen = firstArray.length;
    final int bLen = secondArray.length;
    final byte[] combinedArray = new byte[aLen + bLen];
    System.arraycopy(firstArray, 0, combinedArray, 0, aLen);
    System.arraycopy(secondArray, 0, combinedArray, aLen, bLen);
    return combinedArray;
  }

  public static int[] getIntegerArray(String commaSeperatedString) {
    if (commaSeperatedString == null || commaSeperatedString.isEmpty()) {
      return new int[0];
    }

    final String[] split = commaSeperatedString.split(",");
    int[] integers = new int[split.length];
    if (integers.length == 0) {
      return integers;
    }

    for (int i = 0; i < split.length; i++) {
      if (split[i] == null || split[i].isEmpty()) {
        continue;
      }

      try {
        integers[i] = Integer.parseInt(split[i]);
      } catch (final NumberFormatException e) {
        log.log(Level.SEVERE, e.getMessage(), e);
      }
    }

    return integers;
  }

  public static double[] getDoubleArray(String commaSeperatedString) {
    if (commaSeperatedString == null || commaSeperatedString.isEmpty()) {
      return new double[0];
    }

    final String[] split = commaSeperatedString.split(",");
    double[] doubles = new double[split.length];
    if (doubles.length == 0) {
      return doubles;
    }

    for (int i = 0; i < split.length; i++) {
      if (split[i] == null || split[i].isEmpty()) {
        continue;
      }

      try {
        doubles[i] = Double.parseDouble(split[i]);
      } catch (final NumberFormatException e) {
        log.log(Level.SEVERE, e.getMessage(), e);
      }
    }

    return doubles;
  }

  public static String getCommaSeparatedString(int[] arr) {
    return getCommaSeparatedString(Arrays.stream(arr).boxed().toArray(Integer[]::new));
  }

  public static String getCommaSeparatedString(double[] arr) {
    return getCommaSeparatedString(Arrays.stream(arr).boxed().toArray(Double[]::new));
  }

  public static <T> String getCommaSeparatedString(List<T> list) {
    if (list == null || list.isEmpty()) {
      return null;
    }

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < list.size(); i++) {
      sb.append(list.get(i));
      if (i < list.size() - 1) {
        sb.append(',');
      }
    }

    return sb.toString();
  }

  public static <T> String getCommaSeparatedString(T[] arr) {
    return getCommaSeparatedString(Arrays.asList(arr));
  }

  public static <T> T getRandom(T[] arr) {
    if (arr.length == 0) {
      return null;
    }

    final int randomIndex = new Random().nextInt(arr.length);
    return arr[randomIndex];
  }

  public static boolean containsArgument(String[] args, String argument) {
    if (args == null || args.length == 0) {
      return false;
    }

    for (int i = 0; i < args.length; i++) {
      final String a = args[i];
      if (a != null && !a.isEmpty() && a.equalsIgnoreCase(argument)) {
        return true;
      }
    }

    return false;
  }

  public static int[] toIntegerArray(List<Integer> intList) {
    Object[] objArray = intList.toArray();
    int[] intArray = new int[objArray.length];
    for (int i = 0; i < intArray.length; i++) {
      intArray[i] = (int) objArray[i];
    }
    return intArray;
  }

}

@@ -49,18 +49,108 @@
 ava.
-util.Array
+lang.reflect.Array;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.Collection
 s;%0Ai
@@ -3468,24 +3468,791 @@
 false;%0A  %7D%0A%0A
+  /**%0A   * Removes the specified deleteItem from the input array and returns a trimmed new array instance without null entries.%0A   * The resulting array will have a length -1;%0A   * %0A   * @param input%0A   *          The original array%0A   * @param deleteItem%0A   *          The item to delete%0A   * @return A new array with the length input.length - 1.%0A   */%0A  public static %3CT%3E T%5B%5D remove(T%5B%5D input, T deleteItem) %7B%0A    List%3CT%3E result = new ArrayList%3C%3E();%0A%0A    for (T item : input) %7B%0A      if (!deleteItem.equals(item)) %7B%0A        result.add(item);%0A      %7D%0A    %7D%0A%0A    result.removeAll(Collections.singleton(null));%0A    T%5B%5D newArr = (T%5B%5D) input.getClass().cast(Array.newInstance(input.getClass().getComponentType(), result.size()));%0A    return result.toArray(newArr);%0A  %7D%0A%0A
   public sta

Implement a method that removes an element from an array