import java.util.Iterator;

/**
 * A Java interface for the Set ADT.  All elements in the set are distinct from
 * each other, and are stored with no defined order.
 * 
 * @param <T> The type of item to be stored in the set.
 * 
 * @author Jadrian Miles
 */
public interface Set<T> extends Iterable<T> {
    
    /** Adds the given item to the set, ignoring duplicates. */
    public void add(T item);
    
    /** Removes the given item.
     * @return False if the item wasn't in the set before.
     */
    public boolean remove(T item);
    
    /** Returns whether the given item is in the set.
     * In particular, this method returns true if there exists some item x in
     * the set such that x.equals(item).
     */
    public boolean contains(T item);
    
    /** Returns the number of items in the set. */
    public int size();
    
    /** Returns true if the set is empty. */
    public boolean isEmpty();
    
    /**  Removes all items from the set. */
    public void clear();
    
    /** Returns an iterator over the items in the set (which will access the
     * items in some arbitrary order).
     */
    public Iterator<T> iterator();
    
    /** Returns an array containing the same contents as this set, in an
     * arbitrary order.  Note that, for technical reasons, the type of the items
     * contained in the set can't be communicated properly to the caller, so an
     * array of Objects gets returned.
     * @return an array of length size(), with the same items in it as are
     *         stored in the set.
     */
    public Object[] toArray();
}
