Computers

Design Patterns : Iterator pattern

What is iteration?

In computer science, an iterator is an object which allows a programmer to traverse through all the elements of a collection, regardless of its specific implementation. An iterator is sometimes called a cursor, especially within the context of a database.

Intent

Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Diagram

Applicability

Use Iterator pattern

  • To access an aggregate object’s contents without exposing its internal representation.
  • To support multiple traversals of aggregate objects.
  • To provide a uniform interface for traversing different aggregate structures (that is, to support polymorphic iteration)

Share this post

Related Posts

One thought on “Design Patterns : Iterator pattern”

  1. Anonymous says:

    Splendid article . Will definitely copy it to my blog,surely with link pointing towards you..Thanks.

Comments are closed.