Java Set Intersect intersectionP(Set s1, Set s2)

Here you can find the source of intersectionP(Set s1, Set s2)

Description

intersection P

License

Open Source License

Declaration

static public <T> boolean intersectionP(Set<T> s1, Set<T> s2) 

Method Source Code


//package com.java2s;
import java.util.*;

public class Main {
    static public <T> boolean intersectionP(Set<T> s1, Set<T> s2) {
        Set<T> x = null;//  w  w  w .  j  ava2 s.com
        Set<T> y = null;

        if (s1.size() < s2.size())
            return _intersectionP(s1, s2);
        else
            return _intersectionP(s2, s1);
    }

    static private <T> boolean _intersectionP(Set<T> s1, Set<T> s2) {
        for (Iterator<T> iter = s1.iterator(); iter.hasNext();) {
            Object elt = iter.next();
            if (s2.contains(elt))
                return true;
        }
        return false;
    }
}

Related

  1. intersection(Set sa, Set sb)
  2. intersection(Set first, Set second)
  3. intersection(Set s1, Set s2)
  4. intersection(Set setA, Set setB)
  5. intersection(Set setA, Set setB)
  6. intersects(Set set1, Set set2)
  7. intersectSet(Set orig, Set intersect)
  8. intersectsWith(final Set a, final Set b)
  9. intersectTwoSets(Set a, Set b)