The iterator pattern provides a consistent way to sequentially access items in a collection that is independent of and separate from the underlying collection.
The figure below represents the iterator pattern.
You should use the Interpreter pattern when you want to:
- Access a collection object’s contents without exposing its internal representation.
- Support multiple traversals of objects in a collection.
- Provide a uniform interface for traversing different structures in a collection.