Section of the iterator in STL

xiaoxiao2021-03-05  45

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 :: Difference_Type;

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 (Ostreampara): generate an Ostream iterator for streaming Ostreampara; ostream_iteratror (Ostreampara, Delim): For flow ratio Variables Ostreampara produces an ostream iterator; the output of each element is intervals in Delim. iStream iterator: Read iterator istream_Iterator (istreampara): generates an ISTREAM iterator for streaming iStreampara; istream_iterator (): generates an end_of_file iterator; this is some of the current summary, some inside Things, I have something to understand, but it is not very thorough, and I will wait until a further comprehension, I will rewrite the article.

转载请注明原文地址:https://www.9cbs.com/read-31828.html

New Post(0)