Modeli Iterator ofron një mënyrë për të përshkuar një koleksion në mënyrë sekuenciale pa e ekspozuar strukturën e tij të brendshme. Është kaq themelor sa që është ndërtuar në shumicën e gjuhëve moderne (for-of loops, iterators, generators).
Çfarë bën modeli Iterator
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"
