Analysis of information sources in references of the Wikipedia article "Iterator" in English language version.
You can think of an iterator as pointing to an item that is part of a larger container of items.
A user-defined iterator usually takes the form of a code reference that, when executed, calculates the next item in a list and returns it. When the iterator reaches the end of the list, it returns an agreed-upon value.
•The iterator types iterator and const_iterator are of the forward iterator category
Iterators were introduced as constructs to allow looping over abstract data structures without revealing their internal representation.
An internal iterator is implemented by the member functions of the class which has the iteration logic. An external iterator is implemented by a separate class which can be attached to the object which has iteration logic. The advantage of external iterator is that, many iterators can be made active simultaneously on the existing or same object.
{{cite web}}
: CS1 maint: bot: original URL status unknown (link)Some authors use the term iterator, and others the term generator. Some make subtle distinctions between the two.
{{cite web}}
: CS1 maint: bot: original URL status unknown (link)An index only can be used for containers that (efficiently) support random access (i.e. direct access to an element at a given position). An iterator is a more general concept. Iterators offer efficient traversal of linked lists, files, and a number of other data structures. It often leads to the generation of more efficient code.
{{cite web}}
: CS1 maint: bot: original URL status unknown (link){{cite web}}
: CS1 maint: bot: original URL status unknown (link)•The iterator types iterator and const_iterator are of the forward iterator category