Iterator Pattern
  • is a behavioral design pattern that lets you traverse elements of a collection without exposing its underlying representation (list, stack, tree, etc.).
  • use the Iterator pattern:
    • when your collection has a complex data structure under the hood, but you want to hide its complexity from clients (either for convenience or security reasons)
    • to reduce duplication of the traversal code across your app
    • when you want your code to be able to traverse different data structures or when types of these structures are unknown beforehand

Code Example

TODO

Resources