/** * Interface to a sequential list of objects. * Demonstration program for CSE 143. * @author Hal Perkins * @version 0.1, 4/17/06 */ public interface List { // query functions /** * Return the size of this list * @return number of items currently in the list */ public int size(); /** * Report whether this list is empty or not * @return true if the list is empty, otherwise false */ public boolean isEmpty(); /** * Return the location of an item in this list * @param s the item to be located * @return the index of s in the list if it is present, otherwise -1 */ public int indexOf(E s); /** * Report whether this list contains a particular item * @param s item to search for * @return true if s is contained in the list, false otherwise */ public boolean contains(E s); /** * Return the list item at a given position in this list * @param pos position of desired item (must be 0 <= pos < size) * @return the list item at that position */ public E get(int pos); // list modifications /** * Change the item at a given position to a new value * @param pos position in the list to be changed (must be 0 <= pos < size) * @param s new value to put at that position */ public void set(int pos, E s); /** * Add a new item to the end of this list. * @param s the item to add to the list */ public void add(E s); /** * Add a new item to this list at a specified position * @param pos location where item should be added * (pre: 0 <= pos < size) * @param s item to be added */ public void add(int pos, E s); /** * Remove the item at the specified position from this list * @param pos position of the item to be removed (must be 0 <= pos < size) */ public void remove(int pos); // toString /** * Return a string representation of this list * @return A list of the items in this list separated by commas * and surrounded by brackets */ public String toString(); }