Iterator पॅटर्न संग्रहाला त्याच्या अंतर्गत संरचना उघड न करता क्रमाने ट्रॅव्हर्स करण्याचा मार्ग प्रदान करते. हे इतके मूलभूत आहे की हे बहुतेक आधुनिक भाषांमध्ये निर्मित आहे (for-of लूप्स, iterators, generators).
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"
