n“.
. . a way to access the elements of an aggregate object
sequentially without exposing its underlying representation.”
(DP)
n“any aggregate object”
n“in any desired sequence”
A proposed solution to these
problems and others is the iterator.This is how the gang of four define an iterator: “… a way to access
the elements of an aggregate object [collection] sequentially without
exposing its underlying representation.”We will extend this to mean not just an aggregate object, but any
aggregate object and also open it up non-sequential access.There are, for example, iterators that
return random elements of a collection.