Changes

Jump to: navigation, search

Iterator

149 bytes added, 00:08, 21 January 2007
no edit summary
The '''An Iterator Pattern''' is commonly used in Computer Science as provides the user with a way to access the elements of a collectionsome kind of list sequentially, regardless while keeping the elements of how they were implemented. An iterator may also be called a cursorthat list from exposing their underlying representation.
__TOC__
== Description ==
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.
The purpose of Iterator ties together the object-oriented programming principles known as encapsulation and polymorphism. Using an iterator is to give a user , you can manipulate the objects in a way to process each element of a container while separating collection without explicitly knowing how the user from collection is implemented or what the internal structure collection is made up of the container(Different types of objects perhaps?). This allows the container to store elements however it wants An iterator provides an interface todifferent iteration implementations, while allowing which contain the user details of how to use it as if it were just manipulate a simple list or sequence. An iterator class is usually designed specific collection, including which items in coordination with the container class, which usually provides methods or functions for creating iteratorscollection to show (filtering) and in what order (sorting).
An easy way to think of iterators, is to also think of, Lists, Linked Lists, Binary Trees, and Hash Tables, because they operate very much in the same way that iterators do.
1
edit

Navigation menu