
- [PDF]
Iterators in C++
Iterators are a generalization of pointers in C++ and have similar semantics. They allow a program to navigate through di erent types of containers in a uniform manner.
But we still had to specify what type of data this iterator was pointing to. We want to ultimately write generic functions to work with iterators over any sequence. With templates we can! With …
The ITERATOR pattern gives a clean interface for element-by-element access to a collection, in-dependent of the collection’s shape. Imperative iterations using the pattern have two …
We want the code using iteration to be independent of the type of aggregate being used. Who controls iteration? Who defines the traversal algorithm? How robust is the iterator? STL …
Think of end() as returning the address AFTER the last item (i.e. off the end of the collection or maybe NULL) but really returns an iterator to the one-off-the-end) So as long as your iterator is …
Iterator end() Returns an Iterator object pointing one entry past end of dataset The actual iterator is defined as a class inside the outer class:
Iterators are a generalization of pointers in C++. They allow a program to navigate through different types of containers in a uniform manner.