Iterator

In computer programming, an iterator is an object that enables a programmer to traverse a container, particularly lists.[1][2][3] Various types of iterators are often provided via a container's interface. Though the interface and semantics of a given iterator are fixed, iterators are often implemented in terms of the structures underlying a container implementation and are often tightly coupled to the container to enable the operational semantics of the iterator. An iterator performs traversal and also gives access to data elements in a container, but does not itself perform iteration (i.e., not without some significant liberty taken with that concept or with trivial use of the terminology)[citation needed].

An iterator is behaviorally similar to a database cursor. Iterators date to the CLU programming language in 1974.

  1. ^ Gatcomb, Joshua (Jun 16, 2005). "Understanding and Using Iterators". Perl.com. Retrieved 2012-08-08. 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.
  2. ^ Watt, Stephen M. (September 16, 2006). "A Technique for Generic Iteration and Its Optimization" (PDF). The University of Western Ontario, Department of Computer Science. Retrieved 2012-08-08. Iterators were introduced as constructs to allow looping over abstract data structures without revealing their internal representation.
  3. ^ Alex Allain. "STL Iterators". Cprogramming.com - Your resource for C and C++. Retrieved 2012-08-08. You can think of an iterator as pointing to an item that is part of a larger container of items.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search