Java Utililty Methods Collection Remove

List of utility methods to do Collection Remove

Description

The list of methods to do Collection Remove are organized into topic(s).

Method

CollectionremoveElementsOfList(Collection set, Collection elementsToRemove)
remove Elements Of List
for (E element : elementsToRemove) {
    if (set.contains(element)) {
        set.remove(element);
return set;
voidremoveIfNotPresent(Collection collection, Collection permitted)
remove If Not Present
for (Iterator<T> iter = collection.iterator(); iter.hasNext();) {
    T element = iter.next();
    if (!permitted.contains(element)) {
        iter.remove();
voidremoveOutStrings(Collection values, String newString)
Remove um string da colecao caso seja igual ao parametro 'newString'
for (Iterator<String> iterator = values.iterator(); iterator.hasNext();) {
    String tmp = (String) iterator.next();
    if (tmp.equals(newString)) {
        iterator.remove();
CollectionremoveRightSet(Collection left, Collection right)
remove Right Set
Collection set = new ArrayList(left);
set.removeAll(right);
return set;
booleanremoveSafe(Collection collection, V value)
Type-safe wrapper for Collection#remove(Object) method.
return collection.remove(value);