import java.util.NoSuchElementException; /** * Interface for iterator over ordered lists of objects.
* CSE 373 demonstration program, Winter 2006 * @author Hal Perkins * @version 1/5/06 */ public interface BasicListIterator { /** * Return true if this iteration has more elements in the forward direction * @return true if more elements are available, otherwise false */ public boolean hasNext(); /** * Return the next element in this iteration over the underlying collection * @return the next element in the iteration * @throws NoSuchElementException if the iteration has no more elements */ public Object next() throws NoSuchElementException; /** * Return true if this iteration has more elements in the reverse direction * @return true if more elements are available, otherwise false */ public boolean hasPrevious(); /** * Return the previous element in this iteration over the underlying collection * @return the previous element in the iteration * @throws NoSuchElementException if the iteration has no more elements */ public Object previous() throws NoSuchElementException; /** * Remove from the underlying collection the last element returned by * this iterator. This can only be called once per call to next. * @throws IllegalStateException if next has not yet been called or if * remove is called more than once after a call to next. */ public void remove() throws IllegalStateException; }