List of utility methods to do Set Intersect
Set | getIntersection(Set get Intersection if (a == null || b == null) { return Collections.EMPTY_SET; Set<T> small = (a.size() > b.size()) ? b : a; Set<T> big = (a.size() > b.size()) ? a : b; Set<T> intersection = new HashSet<T>(small); intersection.retainAll(big); return intersection; ... |
Set | getIntersection(Set Returns the intersection of set s1 and set s2 .
if (s1 == null || s2 == null) return new HashSet<T>(); Set<T> result = new HashSet<T>(s1); result.retainAll(s2); return result; |
Collection | intersect(Collection intersect if (isEmpty(set1) || isEmpty(set2)) { return Collections.emptyList(); Set<T> intersection = new LinkedHashSet<T>(); for (T item : set1) { if (item != null && set2.contains(item)) { intersection.add(item); return intersection; |
Set | intersect(final Set Utility method returning the intersection between the given sets (i.e. if (isEmpty(firstSet)) { return secondSet == null ? new HashSet<T>(0) : secondSet; if (isEmpty(secondSet)) { return firstSet; firstSet.retainAll(secondSet); return firstSet; ... |
Set | intersect(Set one, Set two) Form a new set that is the intersection of one set with another set. HashSet n = new HashSet(one.size()); Iterator it = one.iterator(); while (it.hasNext()) { Object v = it.next(); if (two.contains(v)) { n.add(v); return n; |
Set | intersect(Set extends T> set1, Set extends T> set2) Perform the operation intersect on two given sets. Set<T> s = set();
intersect(set1, set2, s);
return s;
|
Set | intersect(Set intersect Set<E> intersect = new HashSet<>(); for (E entryA : a) { if (b.contains(entryA)) { intersect.add(entryA); for (E entryB : b) { if (a.contains(entryB)) { ... |
boolean | intersect(Set Checks that there is at least one matching item between the two sets. for (String s : a) { if (b.contains(s)) return true; return false; |
Set | intersectComparable(Set intersect Comparable List<T> mid = new LinkedList<T>(left); mid.removeAll(right); Set<T> result = new TreeSet<T>(left); result.removeAll(mid); return result; |
Set | intersection(final Set intersection Set<E> set = new HashSet<>(set1); set.retainAll(set2); return Collections.unmodifiableSet(set); |