Home / Fresno naked hot girls to chat with / Invalidating iterators c

Invalidating iterators c

By using an iterator one is isolated from these sorts of consequences.

An actual iterator object may exist in reality, but if it does it is not exposed within the source code of the language.

In procedural languages it is common to use indexing based on a loop counter to loop through all the elements in a sequence such as an array.

Although indexing may also be used with some object-oriented containers, the use of iterators may have some advantages: The ability of a container to be modified while iterating through its elements has become necessary in modern object-oriented programming, where the interrelationships between objects and the effects of operations may not be obvious.

A nice property of a C Standard Template Library (STL) map, multimap, set or multiset is that you can insert or erase elements without invalidating existing iterators.

This is especially useful if you are looping through a container and in the loop body decide if you want to erase the element currently processed.

870 comments

  1. C++ STL c 1997-2017 Mitch Richling https. key_compare c 7!Object of type C p 7!Iterators to a. q 7!Iterators to b. invalidating iterators ON

Leave a Reply

Your email address will not be published. Required fields are marked *

*