Using List Iterators

The programmer who uses an iterator can access the elements in the collection through a simple loop. In the iterator abstraction used in this chapter this access is provided through a trio of routines, atEnd which determines if the collection has more elements, current which returns the current value, and next which updates the iterator.

We note that the Standard Template Library in C++ has the concept of an iterators, but they use different operation names. In C++ operators can be overloaded, and hence they overload the pointer increment and pointer dereference operator to provide the same operations.

The Java library has a datatype Enumeration that describes iterator-like behavior. There they use a pair of methods, hasMoreElements and nextElement, to access the values of a collection.

[audio] [real] Text to accompany slide12, in Chapter 8 of An Introduction to Object-Oriented Programming