Source of 13.27.java


  1: // @author Frank M. Carrano, Timothy M. Henry
  2: // @version 5.0
  3: public boolean hasPrevious()
  4: {
  5:    return (nextIndex > 1) && (nextIndex <= numberOfEntries + 1);
  6: } // end hasPrevious

  8: public T previous()
  9: {
 10:    if (hasPrevious())
 11:    {
 12:       lastMove = Move.PREVIOUS;
 13:       isRemoveOrSetLegal = true;

 15:       T previousEntry = list[nextIndex - 1];
 16:       nextIndex--; // Move iterator back
 17:       return previousEntry;
 18:    }
 19:    else
 20:       throw new NoSuchElementException("Illegal call to previous(); " +
 21:                                        "iterator is before beginning of list.");
 22: } // end previous