Introduction to OOP | Chapter 20: The STL : | next | previous | audio | real | text |
To see what iterators must do, consider a typical algorithm:
template <class T> iterator find (iterator first, iterator last, T & value) { while (first != last && *first != value) ++first; return first; }
Could be used to find values in an array, or in a list:
int data[100]; ... int * where = find(data, data+100, 7); list<int>::iterator where = find(aList.begin(), aList.end(), 7);