import List;

public interface ListIterator
{
  /*
     All methods assume that the underlying list has been initialized.
     All methods assume that the iterator has been initialized.
     No methods change the list.
   */

  // +-----------+---------------------------------------------------------
  // | Observers |
  // +-----------+

  /**
   * Determine if we're at the end of the list.
   * Produces: true if yes, false otherwise.
   * Pre: Default
   * Post: Default
   * Notes: Invalid iterators are nowhere in the list.  It is not
   *   possible to be at the end of the empty list.
   */
  public boolean atEnd();

  /**
   * Determine if we're at the front of the list.
   * Produces: true if yes, false otherwise.
   * Pre: Default
   * Post: Default
   * Notes: Invalid iterators are nowhere in the list.  It is not
   *   possible to be at the end of the empty list.
   */
  public boolean atFront();

  /**
   * Get the current element of the list.
   * Pre: 
   *   (1) The list is nonempty.
   *   (2) The cursor is valid.
   *   (3) The list has not been modified since the iterator
   *       was created or sent to an end of the list.
   * Post: Returns the current element.
   *
   * @exception Exception
   *   If the list is empty or the cursor is invalid.
   */
  public Object getCurrent()
    throws Exception;
  
  /**
   * Determine if the cursor is valid (at an element of the list).
   * Produces: true if yes, false otherwise.
   * Pre: Default
   * Post: Default
   */
  public boolean isValid();

  // +----------+----------------------------------------------------------
  // | Mutators |
  // +----------+

  /**
   * Move the cursor forward one space.
   * Pre:
   *   (1) The list is nonempty.
   *   (2) The cursor is valid.
   *   (3) The cursor is not at the end of the list.
   * Post: The cursor moves to the next element.
   *
   * @exception Exception
   *   If any of the preconditions are not met.
   */
  public void advance()
    throws Exception;

  /**
   * Move the cursor backward one space.
   * Pre:
   *   (1) The list is nonempty.
   *   (2) The cursor is valid.
   *   (3) The cursor is not at the front of the list.
   * Post: The cursor moves to the next element.
   *
   * @exception Exception
   *   If any of the preconditions are not met.
   */
  public void retreat()
    throws Exception;

  /**
   * Move the cursor to the end of the list.
   * Pre: The list is nonempty.
   * Post: 
   *   (1) The cursor moves to the last element.
   *   (2) The cursor is valid.
   *
   * @exception Exception
   *   If the list is empty.
   */
  public void toEnd()
    throws Exception;

  /**
   * Move the cursor to the front of the list.
   * Pre: The list is nonempty.
   * Post: 
   *   (1) The cursor moves to the first element.
   *   (2) The cursor is valid.
   *
   * @exception Exception
   *   If the list is empty.
   */
  public void toFront()
    throws Exception;

} // interface ListIterator

