- Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation
-
The key idea in this pattern is to take the responsibility for access and traversal out of the list object and put it into an iterator object. The Iterator class defines an interface for accessing the list’s elements. An iterator object is responsible for keeping track of the current element; that is, it knows which elements have been traversed already
Iterator
- Defines an interface for accessing and traversing elements.
ConcreteIterator
- Implements the Iterator interface.
- Keeps track of the current position in the traversal of the aggregate.
Aggregate
- Defines an interface for creating an Iterator object.
ConcreteAggregate
- Implements the Iterator creation interface to return an instance of the proper ConcreteIterator.
Iterator Pattern
By gökhan karadaş