Stl invalidating iterators speed dating lesson resources

Posted by / 14-Jan-2018 17:17

Stl invalidating iterators

To request an iterator appropriate for a particular STL templated class, you use the syntax where name is the name of the iterator variable you wish to create and the class_name is the name of the STL container you are using, and the template_parameters are the parameters to the template used to declare objects that will work with this iterator.

I wanted to ignore the iterator completely and just step through the collection with an index: , I discovered that I needed an iterator, which is what I was trying to avoid in the first place.

If you are unfamiliar with the STL, or prefer to do things the "Qt way", you can use these classes instead of the STL classes.

The container classes are implicitly shared, they are reentrant, and they are optimized for speed, low memory consumption, and minimal inline code expansion, resulting in smaller executables.

The Java-style iterators are easier to use and provide high-level functionality, whereas the STL-style iterators are slightly more efficient and can be used together with Qt's and STL's generic algorithms.

Qt also offers a foreach keyword that make it very easy to iterate over all the items stored in a container.

stl invalidating iterators-28stl invalidating iterators-63stl invalidating iterators-42

One thought on “stl invalidating iterators”