List of utility methods to do Array Remove
boolean[] | remove(boolean[] array, boolean value) remove List<Boolean> list = new ArrayList<Boolean>(); for (int i = 0; i < array.length; i++) { if (value != array[i]) { list.add(new Boolean(array[i])); return toArray(list.toArray(new Boolean[list.size()])); |
int[] | remove(int[] a, int[] b) remove Arrays.sort(a); Arrays.sort(b); int[] rest = null; int k = 0; if (a.length > 0 && b.length > 0) { rest = Arrays.copyOf(b, b.length); for (int j = 0; j < b.length; j++) { for (int i = 0; i < a.length; i++) { ... |
String[] | remove(String[] initial, String... toExclude) remove List<String> result = new ArrayList<String>(); result.addAll(Arrays.asList(initial)); result.removeAll(Arrays.asList(toExclude)); return result.toArray(new String[result.size()]); |
String[] | remove(String[] target, String[] needRemoved) remove if (target == null) { throw new RuntimeException("target array is null!"); if (isEmpty(needRemoved)) { return target; String[] result = target; for (String needRemove : needRemoved) { ... |
T[] | remove(T[] a, int i) remove T[] tmp = Arrays.copyOf(a, a.length - 1);
System.arraycopy(a, i + 1, tmp, i, tmp.length - i);
return tmp;
|
E[] | removeAll(E[] array, Object... toRemove) remove All final E[] removed = Arrays.copyOf(array, array.length - count(array, toRemove)); int index = 0; for (E element : array) { if (!contains(toRemove, element)) { removed[index++] = element; return removed; ... |
Map | removeAll(T[] array, Collection Remove the specified elements from the array in-place, replacing them with null . Map<T, Integer> removed = new HashMap<>(); for (int i = 0; i < array.length; i++) { T element = array[i]; if (toRemove.contains(element)) { array[i] = null; removed.put(element, i); return removed; |
T[] | removeAll(T[] items, T item) Remove any occurrence of a given value from an array. int count = 0; for (int i = 0; i != items.length; ++i) { T ith = items[i]; if (ith == item || (item != null && item.equals(ith))) { count++; if (count == 0) { ... |
String | RemoveArgs(String[] args, int startIndex) Remove Args List<String> list = removeFirstTwoArgs(args, startIndex);
String convertedString = convertToString(list);
return convertedString;
|
T[] | removeAt(T[] array, int index) Removes the element at the index from the array and returns a new array. System.arraycopy(array, index + 1, array, index, array.length - index - 1);
return Arrays.copyOf(array, array.length - 1);
|