Iterator

Origin: GoF 95
Reason: To sequentially access all the objects of a collection without exposing the collection's interface and/or representation.
Synopsis: Define an interface with methods to produce a sequence of objects. Make the interface independent of the object's container.
Example: An InventoryBrowser displays InventoryItems encapsulated in an InventoryCollection. The InventoryBrowser does not access the InventoryCollection, but an object that implements the InventoryIterator interface.
Solution:
Collection Class that encapsulates a collection of objects.
IteratorIF Interface that defines the methods to sequentially access the objects in a Collection.
Iterator Implementation of IteratorIF.
CollectionIF Common interface to Collections. Provides method(s) to create Iterators.
See also: Adapter (Iterator is a specialized Adapter)