Iterator Design Pattern (UML Diagrams)
The iterator pattern allows you to define various traversing algorithms for a collection. You may define a forward and backward iteration of a list, breadth-first and depth-first iteration of a tree, etc. The collection is represented by the Aggregate role and the traversing algorithm is defined by the Iterator role.
Design Pattern Parts
The iterator design pattern defines these roles:
- Iterator - traversing algorithm
- Concrete Iterator
- Aggregate - collection of objects
- Concrete Aggregate
Iterator Pattern in Diagrams
The iterator design pattern structure depicted in UML class diagram and the behavior shown in UML sequence diagram.