Summary
An iterator is a language mechanism that facilitates successive enumeration
of all the elements of a collection in some definite order. Java provides an
iterator-like interface called Enumeration. The implementation model imposed
by enumerations is known as cursor objects. It is not a simple task, however,
to develop enumerations for non-linear data structures or for those with
complex control in terms of cursors. This is because the enumeration
procedure for a cursor is confined to use only simple control structures. In
this article, a new iterator mechanism is proposed for Java in which
enumeration procedures can be described as if they were ordinary traversal
procedures. It is fine to use arbitrary control structures such as recursive
calls or infinite loops when developing enumeration procedures. Iterators are
defined to implement the Enumeration interfa... (more)