|
|
List iterators are declared to be of type Listiter<T> (or List_of_piter<T>). This type is declared in List.h.
When a List iterator is declared, it must have a List or another List iterator as initializer. A List iterator, a, declared on a List, L, that is, Listiter<T> a(L), will initially point to the beginning of L, (like a in Figure 2), and it will always point somewhere in that List unless it is changed by assignment. A List iterator, c, initialized with an existing List iterator, d, that is, Listiter<T> c = d;, will point to the same List as d points to, and at the same position in the List (like c and d in Figure 2).
The element immediately to the right of an iterator is called the next element, and the element immediately to the left is the previous element. The current position of the iterator is the index of its next element. Thus in Figure 2, iterators c and d are identical, and T is their next element, and S is their previous element. Iterator a has no previous element, and iterator e has no next element.
List iterators