Code example for HashSet

Methods: add

0
            if (e1 == s.e1 || e1 == s.e2) { // this in included in s
                return s;
            } 
        } 
        // here we know that there are at least 3 distinct elements 
        HashSet<E> r = new HashSet<E>(4);
        r.add(e1);
        if (e2 != null) {
            r.add(e2);
        } 
        r.add(s.e1);
        if (s.e2 != null) {
            r.add(s.e2);
        } 
        return r;
    } 
}