Open main menu

CDOT Wiki β

Changes

Iterator

158 bytes added, 22:18, 20 January 2007
m
no edit summary
The purpose of an iterator is to give a user a way to process each element of a container while separating the user from the internal structure of the container. This allows the container to store elements however it wants to, while allowing the user to use it as if it were just a simple list or sequence. An iterator class is usually designed in coordination with the container class, which usually provides methods or functions for creating iterators.
An easy way to think of iterators, is to look at also think of, Lists, Linked Lists, Binary Trees, and Hash Tables, because they operate very similarlymuch in the same way that iterators do.
=== Implicit Iterators ===
Some object-oriented languages have iterator support included within the language, without having to implement an explicit iterator object. Some of these language include:
* C#
* Java (After 5.0)
* Python
* PERL
* Python
* Java
* C#
=== UML ===
== Code Samples ==
Still in ProgressThe following are samples of code from C#, Check back LaterJava, Python, and PERL, displaying how they implement iterators.
=== C# ===
1
edit