An **iterator** is an object that enables a programmer to traverse a container, such as a list, array, or collection, without exposing the underlying representation. Iterators provide a standard way to access elements in a data structure sequentially, typically allowing the programmer to move through the elements one at a time. ### Key Features of Iterators: 1. **Abstraction**: They hide the complexity of the underlying data structure and provide a uniform interface for traversing different types of collections.
Articles by others on the same topic
A stateful interface exposing a remaining sequence through an availability test and an operation returning and consuming its head. An iterator can represent an infinite sequence without materializing all elements, provided demanded steps terminate. Destructive iterators generally require exclusive ownership of their consumption state; sharing an iterator is not the same as creating a fresh independent traversal.