/** * This interface describes a simple list with operations * to add and remove elements from either end of the list. * * @param type of elements stored in the list */ public interface SimpleList { /** * Adds the given element to the start of the list. * @param elem element to add */ public void addFirst(E elem); /** * Adds the given element to the end of the list. * @param elem element to add */ public void addLast(E elem); /** * Removes the first element from the list. * @return element that was removed * @throws NoSuchElementException if there is no first element */ public E removeFirst(); /** * Removes the last element from the list. * @return element that was removed * @throws NoSuchElementException if there is no last element */ public E removeLast(); /** * Returns the size of the list (i.e. the number of elements * stored in the list. * @return size of list */ public int size(); /** * Returns the element in the list at the given index. * @param index index of element to return * @return element at given index * @throws IndexOutOfBoundsException if given index is invalid */ public E get(int index); /** * Returns the list as a string. The string contains all of the elements * in order from first to last. * @return list as a string */ public String toString(); /** * Returns true of this list is equal to the given list. * Two lists are equal if they contain the same elements in the same order. * @param otherList list to compare to this list * @return true if lists are equal */ public boolean equals(SimpleList otherList); }