1
edit
Changes
Iterator
,no edit summary
An iterator may be though of as a kind of pointer that has two basic operations, referencing one particular element in a collection, and pointing to the next element in the collection (current, and current.next). Depending on the language the iterator is implemented in, other functionality may be added to the iterator object, such as remove and update and so on.
Iterator ties together the [http://en.wikipedia.org/wiki/Object_oriented_programming object-oriented programming ] principles known as encapsulation and [http://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29 polymorphism]. Using an iterator, you can manipulate the objects in a collection without explicitly knowing how the collection is implemented or what the collection is made up of (Different types of objects perhaps?). An iterator provides an interface to different iteration implementations, which contain the details of how to manipulate a specific collection, including which items in the collection to show (filtering) and in what order (sorting).
An easy way to think of iterators, is to also think of, [http://en.wikipedia.org/wiki/List_%28computing%29 Lists], [http://en.wikipedia.org/wiki/Linked_list Linked Lists], [http://en.wikipedia.org/wiki/Binary_tree Binary Trees], and [http://en.wikipedia.org/wiki/Hash_tables Hash Tables], because they operate very much in the same way that iterators do.
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)