Iterator నమూనా సంగ్రహణను (collection) దాని అంతర్గత నిర్మాణాన్ని బహిర్గతం చేయకుండా వరుసగా ప్రయాణించే మార్గాన్ని అందిస్తుంది. ఇది చాలా ప్రాథమికమైనది, కాబట్టి ఇది చాలా ఆధునిక భాషలలో నిర్మితమైనది (for-of లూప్లు, iterators, జెనరేటర్లు).
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"
ఆధునిక భాషలలో నిర్మితమైనది
( item collection) { }
* () { ( i = ; i < n; i++) i; }
( i ()) .(i);
