Het Iterator pattern biedt een manier om een collectie achtereenvolgens te doorlopen zonder de interne structuur ervan bloot te stellen. Het is zo fundamenteel dat het is ingebouwd in de meeste moderne talen (for-of loops, iterators, generators).
Wat het Iterator pattern doet
ITERATOR → access elements of a collection SEQUENTIALLY without exposing its internals:
→ provides a standard way to traverse (next element, has more?)
→ the collection's internal structure (array, tree, linked list) is HIDDEN
→ decouples traversal logic from the collection
→ "iterate without caring how the collection is structured"
