Why Use Iterators


Common Functions
begin
set<int>::iterator iter = mySet.begin();
*

++
Prefix and postfix are both OK. Same as the primitive value, same as the pointer, etc.
end

Usage

Why it Powerful

Map Iterator

Pair

Further Usage

findlower_bound: returns an iterator to the first element not less than the given keyupper_bound: returns an iterator to the first element greater than the given key

- range based for loop

Iterator Type
But some can’t, e.g. list.

- input

- output

- forward

- Bidirectional

- Random

Invalidate
All STL can be erased in this way.
Stream Iterator
