package queues; public interface Collection<E> extends Iterable<E> { /* * Ensures that this collection contains the specified element (optional operation). * Returns true if this collection changed as a result of the call. * Returns false if this collection does not permit duplicates and already * contains the specified element. */ boolean add(E e); //throws IllegalStateException, NullPointerException, //UnsupportedOperationException; /* * Returns true if this collection contains the specified element. * More formally, returns true if and only if this collection contains at least * one element e such that (o==null ? e==null : o.equals(e)). */ boolean contains(Object o); /* * Returns an iterator over the elements in this collection. * There are no guarantees concerning the order in which the elements * are returned (unless this collection is an instance * of some class that provides a guarantee). */ Iterator<E> iterator(); /* * Removes a single instance of the specified element from this collection, * if it is present (optional operation). More formally, removes an element e such that * (o==null ? e==null : o.equals(e)), * if this collection contains one or more such elements. * Returns true if this collection contained the specified element (or equivalently, * if this collection changed as a result of the call). */ boolean remove(Object e); //throws NoSuchElementException, //UnsupportedOperationException /* * Returns the number of elements in this collection. * If this collection contains more than Integer.MAX_VALUE elements, * returns Integer.MAX_VALUE. */ int size(); /* * Returns true if this collection contains no elements */ boolean isEmpty(); /* * Removes all of the elements from this collection (optional operation). * The collection will be empty after this method returns */ void clear(); //throws UnsupportedOperationException /* * Returns an array containing all of the elements in this collection; * the runtime type of the returned array is that of the specified array. * If the collection fits in the specified array, it is returned therein. * Otherwise, a new array is allocated with the runtime type of the specified array * and the size of this collection. * If this collection fits in the specified array with room to spare * (i.e., the array has more elements than this collection), * the element in the array immediately following the end of the collection * is set to null. (This is useful in determining the length of this collection * only if the caller knows that this collection does not contain any null elements.) */ <T> T[] toArray(T[] a); //throws UnsupportedOperationException }