The Iterator Pattern extracts the traversal behavior of a collection into a separate object called an iterator. The iterator traverses the elements of a collection without exposing its underlying representation.
![[Screenshot 2023-09-06 at 4.32.33 PM.png]]
* All traversal details are encapsulated, such as current position and how many elements are still left. Because of this, several iterators can go through the same collection at the same time independently of each other.
* Clients don't create iterators on their own, but instead retrieve them from collections. This way we make sure that the iterator we are using is compatible with that particular collection.