Use of Iterator

xiaoxiao2021-03-06  72

Iterator has iStream_iterator ostream_iterator forward itrator bidirection iterator random access iterator These are some commonly used Iterator depending on functionality. There is also an Insert Iterator or back_insert_Item or back_insert_Item () Insert_Iterator () difference is different in the direction. The functionality of the BACK and Front can be implemented via the user in the direction in INSERT_ITERATOR. When a Container is generally declared, it is generally Mutable Iterator, and the Iterator usually used in the function call is Constant Iterator, because if there is no need to change the Container information, then it is best to Declare Constant Iterator, The conversion of Mutable's Iterator conversion of the CONSTANT ITERATOR is ok, but the conversion in the opposite direction is not feasible. Also when using the iterator must consider an appropriate algorithm, STL encourage efficient combination and discourage unefficient combination. For the set and multiset iterator and constant_iterator are achieved when the constant bidirection iterator actually they are the same type. The reason is that the allowed set The step of modifying the content is to first use the original key delete orre out () through the member function, so it is not allowed to be Mutable. Similar situations exist in the MAP and Multi Map. But the difference is that Value in MAP can be modified.

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

New Post(0)