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"
