List of utility methods to do Set Intersect
Set> | intersection(Set> a, Set> b) Returns intersection of b as a Hashtable containing elements contained both a and b
if (a == null || b == null || a.size() == 0 || b.size() == 0) return Collections.EMPTY_SET; Set<Object> intersection = new HashSet<Object>(); Set<?> tester = (a.size() < b.size()) ? a : b; Set<?> testant = (a.size() < b.size()) ? b : a; for (Object o : tester) { if (testant.contains(o)) intersection.add(o); ... |
Set | intersection(Set intersection Set<E> result = new HashSet<E>(); if (sa == null || sb == null || sa.isEmpty() || sb.isEmpty()) return result; Set<E> smallest = sa.size() < sb.size() ? sa : sb; Set<E> biggest = smallest == sa ? sb : sa; for (E entry : smallest) { if (biggest.contains(entry)) result.add(entry); ... |
Set | intersection(Set Return a new Set with elements that are in the first and second passed collection. Set<T> result = new HashSet<T>(); if ((first != null) && (second != null)) { result.addAll(first); Iterator<T> iter = result.iterator(); boolean found; while (iter.hasNext()) { T item = iter.next(); found = false; ... |
Set | intersection(Set intersection Set<T> s3 = new HashSet<T>(s1); s3.retainAll(s2); return s3; |
Set | intersection(Set Intersection. if (isEmpty(setA) && !isEmpty(setB)) { return Collections.unmodifiableSet(new LinkedHashSet<T>()); if (!isEmpty(setA) && isEmpty(setB)) { return Collections.unmodifiableSet(new LinkedHashSet<T>()); if (isEmpty(setA) && isEmpty(setB)) { return Collections.unmodifiableSet(new LinkedHashSet<T>()); ... |
Set | intersection(Set This method finds the intersection between set A and set B Set<T> intersection = new HashSet<T>(setA); intersection.retainAll(setB); return intersection; |
boolean | intersectionP(Set intersection P Set<T> x = null; Set<T> y = null; if (s1.size() < s2.size()) return _intersectionP(s1, s2); else return _intersectionP(s2, s1); |
boolean | intersects(Set intersects if (set1.size() > set2.size()) return intersects(set2, set1); for (T x : set1) if (set2.contains(x)) return true; return false; |
Set extends Object> | intersectSet(Set extends Object> orig, Set extends Object> intersect) intersect Set if (orig == null) return intersect; if (intersect == null || orig.isEmpty()) return Collections.emptySet(); Set<Object> set = new HashSet<Object>(orig.size()); for (Object p : orig) { if (intersect.contains(p)) set.add(p); ... |
boolean | intersectsWith(final Set extends T> a, final Set extends T> b) intersects With if (a == b) { return true; final Set lSet, sSet; if (a.size() >= b.size()) { lSet = a; sSet = b; } else { ... |