Code example for Collection

Methods: iterator, size

0
    public boolean contains(Object o) {
        return (first == o || first.equals(o) || second == o || second.equals(o));
    } 
 
    public boolean containsAll(Collection<?> c) {
        if (c.size() > 2)
            return false; 
        Iterator<?> iter = c.iterator();
        Object c_first = iter.next();
        Object c_second = iter.next();
        return this.contains(c_first) && this.contains(c_second);
    } 
 
    public boolean isEmpty() { 
        return false; 
    } 
 
    public Iterator<T> iterator() {
        return new PairIterator(); 
    }