Quantcast
Viewing latest article 2
Browse Latest Browse All 10

Iterator

Description:

Is used to traverse a container and access the container’s elements. The iterator pattern decouples algorithms from containers.Containers may be a list , graph ,tree etc.

Benefits:

  • Supports variations in the traversal of a collection
  • Simplifies the interface of the collection

When to use:

  • Access collection object’s contents without exposing its internal representation
  • Support multiple traversals of objects in a collection
  •  Provide a uniform interface for traversing different structures in a collection

 

Diagram:

Image may be NSFW.
Clik here to view.

Code samples are below and can be downloaded here.



Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 2
Browse Latest Browse All 10

Trending Articles