The iterator has played a key role in STL and the model technology. Recently, I once again tempered the various types of iterators, and now I wrote it, it is summed up:
First, iterators can generally be classified as follows:
Read the iterator forward: Input Iterator
Write an iterator forward: Output Iterator
Forward iterator: Forword Iterator :: Public Input Iterator: Most of the functionality of all functions of the input Iterator OUTPUT
Two-way iterator: (Bidirectional Iterator :: Public Forword Iterator: The ability to add back traversal on the basis of the Forword iterator
Random iterator: Random Access Iterator :: Bidirectional Iterator: The ability to add random memory is added based on the Bidirectional iterator.
Second, iterator related auxiliary functions:
1. Mobile function of iterator: Void Advance (InputITeraotr & Pos, Dist N);
2, distance function between iterators: Dist Distance (InputITeraotor & Pos1, InputITeraotr & Pos2)
The type: dist is: iTERATRO_TRAITS
3. Switch the function of the content referred to the two iterators: Void ITER_SWAP (ForWordItemrator & Pos1, ForwordItemrator & Pos2)
Third, an iterator's adapter:
(Or three special iterators: reverse iterator (Reverse_iterator), insert iterator, streaming device)
Reverse iterator: Comparison is easy to understand: reverse_iterator ();
Insert iterators include: Back_Insert_iterator The conversion generated function is: back_insertr (cont) Front_Insert_iterator front_inserter (cont) Insert_Iterator Inserter (Cont, POS)
A streaming device: This iterator is primarily a starting point and end point of Stream as an algorithm.
There are two main types of strengthens: ostream iterators: write iteratory ostream_iteratror