// guts of Set.java package java.util; public interface Set extends Collection { // Query Operations int size(); boolean isEmpty(); boolean contains(Object o); Iterator iterator(); Object[] toArray(); T[] toArray(T[] a); // Modification Operations boolean add(E o); boolean remove(Object o); // Bulk Operations boolean containsAll(Collection c); boolean addAll(Collection c); boolean retainAll(Collection c); boolean removeAll(Collection c); void clear(); // Comparison and hashing boolean equals(Object o); int hashCode(); } // Surprise! All same as Collection, but different post-conditions // specified for add and addAll supposed to prevent duplicate elements. // Of course, programmers must honor this "contract" for it to work.