From the course: C#: Design Patterns Part 1

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Iterator pattern definition

Iterator pattern definition - Python Tutorial

From the course: C#: Design Patterns Part 1

Iterator pattern definition

- [Instructor[To iterate is to move continuously forward. The iterator pattern is also known by the names cursor or enumerator. It was in use long before it was documented and codified as a software design pattern. Iterators operate on an aggregate object, a collection of some sort. Most commonly, this is a list, but it could be a tree or any other set of like items. The goal of the iterator is to separate moving through that set of items from the set of items itself. An iterator allows access to elements in a collection without knowing the type, structure, or end. Iterator provides the ability to go to the next item in a sequence and access that item. The diagram is straightforward. A collection provides a way to get an iterator, and that iterator allows you to get the current item, move to the next item, or start over. The iterator allows you to keep the collection interface cleaner, and prevent changing the list type to…

Contents