Iterator Pattern
Context
- An aggregate object contains element objects
- Clients need access to the element objects
- The aggregate object should not expose its internal
structure
- Multiple clients may want independent access
Solution
- Define an iterator that fetches one element at a time
- Each iterator object keeps track of the position of the next
element
- If there are several aggregate/iterator variations, it is best
if the aggregate and iterator classes realize common interface
types.
previous |
start |
next .... [Slide 11] ....