An iterator is an object-oriented programming pattern that allows traversal through a collection, agnostic of the actual implementation or object addresses in physical memory. It is one of the Gang of Four's behavioral design patterns.
An iterator is an object-oriented programming pattern which, for the most part, functions similarly to a pointer to an object inside a collection with the added ability to traverse through the collection in a defined manner, agnostic of the actual implementation or even object addresses in physical memory.
The following types of iterators are the most common:
- Random Access
Iterators may be read-only, write-only or read-write.
- Forward iterators typically have a
- Reverse iterators typically have a
- Iterators sometimes have a
This is one of the Gang of Four's behavioral design-patterns, first published in Gamma et al.'s book "Design Patterns: Elements of Reusable Object-Oriented Software".