Iterator pattern ஒரு collection-ஐ வரிசையாக traverse செய்வதற்கான வழிமுறையை வழங்குகிறது, அதன் internal structure-ஐ expose செய்யாமல். இது மிகவும் அடிப்படையான pattern ஆகும், பெரும்பாலான நவீன languages-ல் (for-of loops, iterators, generators) built-in ஆக இருக்கிறது.
Iterator pattern என்ன செய்கிறது
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"
