Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Iterator
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Object that enables processing collection items in order}} {{More citations needed|date=June 2010}}In [[computer programming]], an '''iterator''' is an [[object (computing)|object]] that progressively provides access to each item of a [[Collection (abstract data type)|collection]], in order.<ref>{{cite web |url = https://www.perl.com/pub/2005/06/16/iterators.html/ |title = Understanding and Using Iterators |last1 = Gatcomb |first1 = Joshua |publisher = Perl.com |date=Jun 16, 2005 |quote = 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. |access-date = 2012-08-08 }}</ref><ref name=definition>{{cite web |url = https://www.csd.uwo.ca/~watt/pub/reprints/2006-wgp-jflow.pdf |date=September 16, 2006 |title = A Technique for Generic Iteration and Its Optimization |last1 = Watt |first1 = Stephen M. |publisher = The University of Western Ontario, Department of Computer Science |quote = Iterators were introduced as constructs to allow looping over abstract data structures without revealing their internal representation. |access-date = 2012-08-08 }}</ref><ref>{{cite web | url = http://www.cprogramming.com/tutorial/stl/iterators.html | title = STL Iterators | author = Alex Allain | publisher = Cprogramming.com - Your resource for C and C++ | quote = You can think of an iterator as pointing to an item that is part of a larger container of items. | access-date = 2012-08-08 }}</ref> A collection may provide multiple iterators via its [[Interface (object-oriented programming)|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 [[Coupling (computer programming)|coupled]] to the collection to enable the operational semantics of the iterator. An iterator is behaviorally similar to a [[cursor (databases)|database cursor]]. Iterators date to the [[CLU (programming language)|CLU]] programming language in 1974.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)