Iterator
Iterator
Main page

Iterator

logo
Community Hub0 subscribers
What are your thoughts?
Be the first to start a discussion here.
Be the first to start a discussion here.
Iterator

In computer programming, an iterator is an object that progressively provides access to each item of a collection, in order.

A collection may provide multiple iterators via its interface that provide items in different orders, such as forwards and backwards.

An iterator is often implemented in terms of the structure underlying a collection implementation and is often tightly coupled to the collection to enable the operational semantics of the iterator.

An iterator is behaviorally similar to a database cursor.

Iterators date to the CLU programming language in 1974.

An iterator provides access to an element of a collection (element access) and can change its internal state to provide access to the next element (element traversal). It also provides for creation and initialization to a first element and indicates whether all elements have been traversed. In some programming contexts, an iterator provides additional functionality.

An iterator allows a consumer to process each element of a collection while isolating the consumer from the internal structure of the collection. The collection can store elements in any manner while the consumer can access them as a sequence.

In object-oriented programming, an iterator class is usually designed in tight coordination with the corresponding collection class. Usually, the collection provides the methods for creating iterators.

See all
User Avatar
No comments yet.