List of utility methods to do Collection Remove
T | remove(final int index, final Collection remove if (!isEmptyOrNull(collection)) { int i = 0; for (Iterator<T> it = collection.iterator(); it.hasNext();) { final T removed = it.next(); if (i == index) { it.remove(); return removed; i++; return null; |
List | removeAll(Collection collection, Collection remove) Removes the elements in remove from collection .
List list = new ArrayList(); for (Iterator iter = collection.iterator(); iter.hasNext();) { Object obj = iter.next(); if (remove.contains(obj) == false) { list.add(obj); return list; ... |
void | removeAll(Collection source, Set remove) remove All Iterator i = remove.iterator();
while (i.hasNext()) {
source.remove(i.next());
|
boolean | removeAll(Collection> c, Iterable> elts) Remove the given elements from a collection. if (elts instanceof Collection<?>) { return c.removeAll((Collection<?>) elts); } else { boolean result = false; for (Object elt : elts) { result |= c.remove(elt); return result; ... |
void | removeAll(Collection> c, Object e) Removes all occurrences of e from c .
if (c instanceof List) { List<?> list = (List<?>) c; int index = -1; do { index = list.lastIndexOf(e); if (index != -1) list.remove(index); } while (index != -1); ... |
Collection | removeAll(Collection Removes objects in array to the given collection for (T obj : array) c.remove(obj); return c; |
Collection | removeAll(Collection Removes objects in array to the given collection for (T obj : array) { c.remove(obj); return c; |
void | removeAll(Collection remove All if (elements != null) for (int i = 0; i < elements.length; i++) ret.remove(elements[i]); |
List | removeAll(Collection remove All List<T> list = new ArrayList<T>(); for (Iterator<T> iter = collection.iterator(); iter.hasNext();) { T obj = iter.next(); if (remove.contains(obj) == false) { list.add(obj); return list; ... |
boolean | removeAll(Collection Removes all elements from the Collection . if (collection != null && elementsToRemove != null) { boolean result = false; for (T toAdd : elementsToRemove) { result = collection.remove(toAdd) || result; return result; } else { return false; ... |