/* Author: Jeff Dalton * Updated: Wed May 9 19:04:16 2001 by Jeff Dalton */ package ix.util.lisp; import java.util.*; /** * An implementation of Iterator for LLists. */ public class LListIterator implements Iterator { protected LList at = null; // for the next next() public LListIterator(LList list) { this.at = list; } public boolean hasNext() { return at != Lisp.NIL; } public Object next() { if (at != Lisp.NIL) { Object elt = at.car(); at = at.cdr(); return elt; } else throw new NoSuchElementException("at end of LList"); } public void remove() { throw new UnsupportedOperationException("Cannot remove from an LList"); } }