import java.util.*; /** Abstract data type for a dynamically growing list. The Iterator * returned by iterator() must support the remove() method. * @author Jacob Whitehill */ public interface List12 extends Iterable { /** Adds the specified Object o, which may be null, to the * front of the list (i.e., at the head). * @param o the object to add to the list. */ void addToFront (Object o); /** Adds the specified Object o, which may be null, to the * back of the list (i.e., at the tail). * @param o the object to add to the list. */ void addToBack (Object o); /** Equivalent to addToBack. * @param o the object to add to the list. */ void add (Object o); /** Removes and returns the element at the front of the list. * @return the element that was removed from the front of the list. * @throws NoSuchElementException if the list was empty. */ Object removeFront () throws NoSuchElementException; /** Removes and returns the element at the back of the list. * @return the element that was removed from the back of the list. * @throws NoSuchElementException if the list was empty. */ Object removeBack () throws NoSuchElementException; /** Removes the first occurrence (ordered from front to * back, i.e., head to tail of the list) of the specified * Object o from the list, if it exists. o may be null; if * it is, then this method removes the first element in * the list that is null. Otherwise, this method removes * the first element in the list that equals() * o (if any such element exists). * @return true if an element was removed, or * false otherwise. */ boolean remove (Object o); /** Removes all elements from the list. */ void clear (); /** Returns the element stored at location index, where index 0 * is the element stored at the head of the list and size()-1 is * the index of the element at the tail of the list. * @param index the index of the element to retrieve. * @throws IndexOutOfBoundsException if the index is invalid. * @return the Object at the specified index. */ Object get (int index) throws IndexOutOfBoundsException; /** Returns the number of elements (null or otherwise) currently stored in the * list. * @return the number of elements stored in the list. */ int size (); /** Returns whether the specified Object o is contained in the list. o * may be null. * @param o the object whose presence in the list should be determined. * @return whether o is contained in the list. */ boolean contains (Object o); }