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!
==Pattern== {{Main|Iterator pattern}} 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'').<ref name=ExternalInternal>{{cite web |url = http://www.careerride.com/ |title = Difference between an external iterator and an internal iterator |date = 2009-04-03 |publisher = CareerRide.COM |archive-url = https://web.archive.org/web/20120919061643/http://careerride.com/ |archive-date = 2012-09-19 |quote = 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. |access-date = 2012-08-08 |url-status = bot: unknown }}</ref> 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.<ref name=definition /> 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. A [[loop counter]] is sometimes also referred to as a loop iterator. A [[loop counter]], however, only provides the traversal functionality and not the element access functionality.
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)