Here you can find the source of removed(Collection
Parameter | Description |
---|---|
a | list of element of type T |
b | list of element of type T |
public static <T> Collection<T> removed(Collection<T> a, Collection<T> b)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; public class Main { /**/*from w w w . j a v a 2s.c o m*/ * returns the elements added in List a with respect to b * * @param a list of element of type T * @param b list of element of type T * @return list list of element of type T */ public static <T> Collection<T> removed(Collection<T> a, Collection<T> b) { Collection<T> aCopy = new ArrayList<T>(a); Collection<T> bCopy = new ArrayList<T>(b); Collection<T> added = added(a, b); aCopy.removeAll(added); bCopy.removeAll(aCopy); return bCopy; } /** * returns the elements added in List a with respect to b * * @param a list of element of type T * @param b list of element of type T * @return list list of element of type T */ public static <T> Collection<T> added(Collection<T> a, Collection<T> b) { Collection<T> aCopy = new ArrayList<T>(a); Collection<T> bCopy = new ArrayList<T>(b); aCopy.removeAll(bCopy); return aCopy; } }