Java Utililty Methods Set Intersect

List of utility methods to do Set Intersect

Description

The list of methods to do Set Intersect are organized into topic(s).

Method

Setintersection(Set a, Set b)
Returns intersection of a and 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);
...
Setintersection(Set sa, Set sb)
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);
...
Setintersection(Set first, Set second)
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;
...
Setintersection(Set s1, Set s2)
intersection
Set<T> s3 = new HashSet<T>(s1);
s3.retainAll(s2);
return s3;
Setintersection(Set setA, Set setB)
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>());
...
Setintersection(Set setA, Set setB)
This method finds the intersection between set A and set B
Set<T> intersection = new HashSet<T>(setA);
intersection.retainAll(setB);
return intersection;
booleanintersectionP(Set s1, Set s2)
intersection P
Set<T> x = null;
Set<T> y = null;
if (s1.size() < s2.size())
    return _intersectionP(s1, s2);
else
    return _intersectionP(s2, s1);
booleanintersects(Set set1, Set set2)
intersects
if (set1.size() > set2.size())
    return intersects(set2, set1);
for (T x : set1)
    if (set2.contains(x))
        return true;
return false;
SetintersectSet(Set orig, Set 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);
...
booleanintersectsWith(final Set a, final Set b)
intersects With
if (a == b) {
    return true;
final Set lSet, sSet;
if (a.size() >= b.size()) {
    lSet = a;
    sSet = b;
} else {
...