Vzor Iterator poskytuje způsob, jak procházet kolekci sekvenčně bez odhalení její vnitřní struktury. Je to tak fundamentální, že je zabudovaný ve většině moderních jazyků (for-of smyčky, iterátory, generátory).
Co vzor Iterator dělá
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"
