/**
 * A sorted list of Comparable objects.
 * <p>
 * Items in the list are inserted in sorted order.
 * x comes before y in the list if x.compareTo(y) < 0.
 * Duplicate items in the list may or may not occur 
 *   depending on the implementation.
 *
 * @author Zach Tomaszewski, for ICS211-1
 * @version 09 Oct 2003
 */

public interface SortedList {

  /**
   * Determines whether or not the list is empty.
   * 
   * @return false if there are no elements in the list (size() == 0),
   *    otherwise returns true.
   */
  public boolean isEmpty();
   
  
  /**
   * Returns the size of the list.
   *
   * @return the number of elements in the list
   */
  public int size();
  
  
  /**
   * Adds the given item to the list in its correct sorted-order position.
   * Duplicate items (where x.compareTo(y) == 0) may or may not 
   *  be supported, depending on the implementing class.
   * x comes before y in the list if x.compareTo(y) < 0.
   *
   * @param item   a java.lang.Comparable object
   * @throws SortedListException   if the item cannot be added to the list
   */
  public void add(Comparable item) throws SortedListException;


  /**
   * Removes the given item from the list.
   * Whether all matching items or only one are removed depends on the
   *  implementation.
   *
   * @param item the java.lang.Comparable object to remove from this list.
   * @throws SortedListException  if the object cannot be removed
   *           (such as when the item is not in the list)
   */
  public void remove (Comparable item) throws SortedListException;

  
  /**
   * Remove the object at the given position in the list.
   * The given position must be in the range of the list:
   *   1 <= position <= size()
   *
   * @param position  the position to remove from the list
   * @throws SortedListException  if the object cannot be removed
   *           (such as when position is < 1 or > size())
   */
  public void remove (int position) throws SortedListException;
 
  
  /**
   * Gets the object at the given position in the list.
   * Does not affect the state of the list.
   *
   * @param position  the position of the item to get
   * @return          the object in that position in the list
   * @throws SortedListException  if the object cannot be returned
   *           (such as when position is < 1 or > size())
   */
  public Comparable get (int position) throws SortedListException;
  
  
  /**
   * Removes all elements from this list.  
   * size() is then 0.
   */
  public void removeAll ();

  
}//end interface
