Example usage for java.util List removeAll

List of usage examples for java.util List removeAll

Introduction

In this page you can find the example usage for java.util List removeAll.

Prototype

boolean removeAll(Collection<?> c);

Source Link

Document

Removes from this list all of its elements that are contained in the specified collection (optional operation).

Usage

From source file:Main.java

public static List romove(List lista, List listb) {
    lista.removeAll(listb);
    return lista;
}

From source file:Main.java

public static <E extends Object> void removeNullFromList(List<E> list) {
    list.removeAll(Collections.singleton(null));
}

From source file:Main.java

public static <T> Collection<T> minus(Collection<T> col1, Collection<T> col2) {
    List<T> list = clone(col1);
    list.removeAll(col2);
    return list;/*from  w  ww .  j  av  a  2s  .  c  om*/
}

From source file:Main.java

public static <T> void removeAll(List<T> removeFrom, List<? extends T> c2) {
    removeFrom.removeAll(c2);
}

From source file:Main.java

public static <T> void removeAll(List<? super T> removeFrom, List<? extends T> c2) {
    removeFrom.removeAll(c2);
}

From source file:Main.java

public static void copy(List<Integer> destList, List<Integer> srcList) {
    destList.removeAll(destList);
    for (Integer val : srcList) {
        destList.add(val);
    }// w w  w .j a  va 2s  .c o m
}

From source file:Main.java

public static <E> Collection<E> diff(Collection<E> l, Collection<E> r) {
    if (isEmpty(l) || isEmpty(r))
        return l;

    List<E> s = new ArrayList<E>(l);
    s.removeAll(r);

    return s;/*w w  w.j av  a  2 s. c  o  m*/
}

From source file:Main.java

public static <T> List<T> minus(List<T> initialList, List<T> elementsToRemove) {
    List<T> minusedList = new ArrayList<T>(initialList);
    minusedList.removeAll(elementsToRemove);
    return minusedList;
}

From source file:Main.java

public static <T> void diff(Collection<T> from, Collection<T> to, Consumer<? super T> foreachAdd,
        Consumer<? super T> foreachRemove) {
    List<T> added = new ArrayList<>(to);
    added.removeAll(from);
    added.forEach(foreachAdd);// w w  w . j  av a 2 s. c o  m

    List<T> removed = new ArrayList<>(from);
    removed.removeAll(to);
    removed.forEach(foreachRemove);
}

From source file:Main.java

/**
 * Removes all null, empty and short (<3 char) Strings, trimming elements from the ArrayList
 * @param listOfStrings/* w  ww  .j a va 2  s .c  om*/
 * @return
 */
public static List<String> filterInvalidCandidates(List<String> listOfStrings) {
    listOfStrings.removeAll(Arrays.asList("", null));
    List<String> validListOfStrings = new ArrayList<>();
    if (listOfStrings.size() > 0) {
        for (String eachString : listOfStrings) {
            if (eachString.length() > 3) {
                validListOfStrings.add(eachString);
            }
        }
    }
    return validListOfStrings;
}