List of usage examples for java.util Set removeAll
boolean removeAll(Collection<?> c);
From source file:Main.java
public static <T> Set<T> difference(Collection<T> s1, Collection<T> s2) { Set<T> ns = new HashSet<T>(s1); ns.removeAll(s2); return ns;/*from w w w .ja v a 2 s.co m*/ }
From source file:Main.java
public static <T> Collection<T> diff(Collection<T> a, Collection<T> b) { Set<T> set = new HashSet<T>(a); set.removeAll(b); return set;/* w ww . j a va2 s .com*/ }
From source file:Main.java
public static <E> Set<E> difference(final Set<E> set1, final Set<E> set2) { Set<E> set = new HashSet<>(set1); set.removeAll(set2); return Collections.unmodifiableSet(set); }
From source file:Main.java
public static void performDifference(Set<String> s1, Set<String> s2) { Set<String> s1Differences2 = new HashSet<>(s1); s1Differences2.removeAll(s2); Set<String> s2Differences1 = new HashSet<>(s2); s2Differences1.removeAll(s1);/*from w ww . j a v a 2 s . c o m*/ System.out.println("s1 difference s2: " + s1Differences2); System.out.println("s2 difference s1: " + s2Differences1); }
From source file:Main.java
public static <T> Set<T> difference(Set<T> setA, Set<T> setB) { Set<T> tmp = new TreeSet<T>(setA); tmp.removeAll(setB); return tmp;/*ww w .ja va 2s . c o m*/ }
From source file:Main.java
public static <T> Set<T> diff(Set<T> s1, Set<T> s2) { Set<T> result = new HashSet<T>(s1); result.removeAll(s2); return result; }
From source file:Main.java
/** * One way diff./*from w w w .j av a 2 s . c o m*/ * * @param <T> the generic type * @param set1 the set1 * @param set2 the set2 * @return Uses the diff paradigm. Non destructive set1 - set2 */ public static <T> Set<T> oneWayDiff(Set<T> set1, Set<T> set2) { Set<T> tempSet1 = new HashSet<T>(set1); tempSet1.removeAll(set2); return tempSet1; }
From source file:Main.java
/** * This method finds the difference between set A and set B i.e. set A minus set B * @param setA set A//w w w . j ava 2s . com * @param setB set B * @param <T> type * @return a new set containing the difference */ public static <T> Set<T> difference(Set<T> setA, Set<T> setB) { Set<T> difference = new HashSet<T>(setA); difference.removeAll(setB); return difference; }
From source file:Main.java
/** * Returns the difference of two sets (S1\S2). It calls {@link Set#removeAll(java.util.Collection)} but returns a * new set containing the elements of the difference. * /* w w w .ja v a2 s . com*/ * @param set1 * the first set * @param set2 * the second set * @return the difference of the sets */ public static <V> Set<V> difference(Set<V> set1, Set<V> set2) { Set<V> difference = new HashSet<V>(); difference.addAll(set1); difference.removeAll(set2); return difference; }
From source file:SetOps.java
/** * // w w w . j a va 2 s .c om * @param <T> * @param s1 * @param s2 * @return the (asymmetric) set difference of s1 and s2. (For example, the * set difference of s1 minus s2 is the set containing all of the * elements found in s1 but not in s2.) */ public static <T> Set<T> difference(Set<T> s1, Set<T> s2) { Set<T> difference = new LinkedHashSet<T>(s1); difference.removeAll(s2); return difference; }