The iterator pattern is based on two abstract classes or interfaces, which can be implemented by pairs of concrete classes. The class diagram is as follows:
The following classes are used in the iterator pattern:
- Aggregate: The abstract class that should be implemented by all the classes and can be traversed by an iterator. This corresponds to the java.util.Collection interface.
- Iterator: This is the iterator abstraction that defines the operations to traverse the aggregate object along with the one to return the object.
- ConcreteAggregate: Concrete aggregates can implement internally different structures, but expose the concrete ...