Iterator


Usage
  • Also known as: Cursor
  • Sequentially access the elements of a collection
  • Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation
Diagram
Iterator
Participants
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.