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 <E> Collection<E> same(Collection<E> l, Collection<E> r) {
    if (isEmpty(l) || isEmpty(r))
        return null;

    List<E> s = new ArrayList<E>(l);
    s.removeAll(r);
    List<E> k = new ArrayList<E>(l);
    k.removeAll(s);/*from  ww  w. ja  v  a2 s .c om*/
    return k;
}

From source file:Main.java

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

    List<E> s = new ArrayList<E>(l);
    s.removeAll(r);
    r.removeAll(l);/*from   www.  ja v  a2  s .  c  o m*/

    return s;
}

From source file:Main.java

public static <T> List<T> newElements(List<T> old_list, List<T> new_list) {
    if (new_list == null)
        return new ArrayList<T>();
    List<T> retval = new ArrayList<T>(new_list);
    if (old_list != null)
        retval.removeAll(old_list);
    return retval;
}

From source file:Main.java

public static List<Integer> diff(List<Integer> l1, List<Integer> l2) {
    List<Integer> aux1 = new ArrayList<Integer>(l1);
    List<Integer> aux2 = new ArrayList<Integer>(l2);
    aux1.removeAll(l2);
    aux2.removeAll(l1);/*from  ww w . ja  v a  2 s .  c  om*/
    aux1.addAll(aux2);
    return aux1;
}

From source file:Main.java

public static List substract(List srcList, List destList) {
    List list = new ArrayList<>(Arrays.asList(new Object[srcList.size()]));
    Collections.copy(list, srcList);
    list.removeAll(destList);
    return list;/*from   ww w.  j av  a 2 s  .  c om*/
}

From source file:br.ufpr.inf.opla.patterns.util.AdapterUtil.java

public static List<Interface> getAllTargetInterfaces(Element adaptee) {
    List<Interface> targetInterfaces = new ArrayList<>();

    List<Element> adapteeSuperElements = ElementUtil.getAllSuperElements(adaptee);
    adapteeSuperElements.add(adaptee);//www  . j ava2 s . c  o m
    List<Relationship> allRelationships = ElementUtil.getRelationships(adapteeSuperElements);
    for (Relationship relationship : allRelationships) {
        Element usedElementFromRelationship = RelationshipUtil.getUsedElementFromRelationship(relationship);
        if (usedElementFromRelationship != null && adapteeSuperElements.contains(usedElementFromRelationship)) {
            Element client = RelationshipUtil.getClientElementFromRelationship(relationship);
            if (client instanceof Class && !((Class) client).isAbstract()) {
                List<Interface> allSuperInterfaces = ElementUtil.getAllSuperInterfaces(client);
                allSuperInterfaces.remove(adaptee);
                allSuperInterfaces.removeAll(adapteeSuperElements);
                targetInterfaces = new ArrayList<>(CollectionUtils.union(targetInterfaces, allSuperInterfaces));
            }
        }
    }
    return targetInterfaces;
}

From source file:com.ardoq.mavenImport.ArdoqMavenImport.java

public static void ensureFieldExist(FieldService fieldService, Model model, Map<String, Field> fields,
        String fieldName, List<String> componentTypes, FieldType fieldType, String defaultValue) {
    Field field = fields.get(fieldName);
    if (field == null) {
        field = fieldService.createField(
                new Field(fieldName, fieldName, model.getId(), componentTypes, fieldType, defaultValue));
        return;/*from w  w  w  .j a v a  2s  .  c  o  m*/
    }
    // ensure that the field is associated with the correct component types
    List<String> missingComponentTypes = new LinkedList<String>(componentTypes);
    missingComponentTypes.removeAll(field.getComponentType());
    if (missingComponentTypes.isEmpty()) {
        return;
    }
    field.getComponentType().addAll(missingComponentTypes);
    fieldService.updateField(field.getId(), field);
}

From source file:Main.java

public static void getBJ() {
    List<Integer> l1 = new ArrayList<Integer>();
    l1.add(1);/*from   ww  w .  j  a v a 2  s  .  c o m*/
    l1.add(2);
    l1.add(3);
    l1.add(4);
    List<Integer> l = new ArrayList<Integer>();
    for (Integer item : l1) {
        if (item == 2 || item == 7) {
            l.add(item);
        }
    }
    l1.removeAll(l);
    l.addAll(l1);
    System.out.println(l);
}

From source file:com.chiralbehaviors.CoRE.phantasm.graphql.schemas.JooqSchema.java

public static JooqSchema meta(PhantasmProcessor processor) {
    List<Table<?>> manifested = Ruleform.RULEFORM.getTables();
    manifested.removeAll(Arrays.asList(new Table[] { RULEFORM.EXISTENTIAL, RULEFORM.EDGE_AUTHORIZATION,
            RULEFORM.EDGE, RULEFORM.FACET, RULEFORM.WORKSPACE_LABEL, RULEFORM.JOB, RULEFORM.JOB_CHRONOLOGY,
            RULEFORM.FACET_PROPERTY, RULEFORM.EDGE_PROPERTY }));
    return new JooqSchema(manifested, processor);
}

From source file:com.github.pmerienne.cf.testing.dataset.DatasetUtils.java

public static List<Rating> removeRandomRatings(final long user, int count, List<Rating> allRatings) {
    List<Rating> userRatings = Lists.newArrayList(Iterables.filter(allRatings, new Predicate<Rating>() {
        @Override/*  ww w.java 2 s.c o  m*/
        public boolean apply(Rating input) {
            return input.i == user;
        }
    }));
    List<Rating> removedRatings = ListUtils.randomSubList(userRatings, count);

    allRatings.removeAll(removedRatings);
    return removedRatings;
}