Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi,

On 14 February 2011 21:05, Michael Meeks <michael.meeks@novell.com> wrote:

       I wonder if the stlport iterators were simply more robust against
changes in the underlying structures. Is this a list it is iterating or
a hash ? If the latter then changes in the 'hash' had undefined (but
non-crashy) behaviour with stlport.

I remember writing some code a number of years ago that iterated over
a map and deleted 'expired' items during iteration.

Using libstdc++ on CentOS 4 vintage I definitely had to take a local
copy of the iterator, move on to the next item using ++ii, then delete
the item using the copy of the iterator (and never use the copy
again), otherwise it would crash.

The code didn't look as pretty as using a simple for
(std::map<string,bar>::iterator ii(foo.begin(); ii!= foo.end(); ++ii)
loop, but at least it worked.

I think there is no guarantee in STL for certain data types (like
maps) when you erase the value at the iterator.  I never used the hash
- it always seemed to use more memory than maps, and wasn't any faster
with what I was trying to do.

STLport might be a bit more clever about this kind of (ab)use, or it
might just be luck.

Regards
Steven

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.