🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2481

Re: Modifying STL containers via an iterator

#2481
From: John Max Skaller
Date: Wed, 08 Nov 1995 17:25
27 lines
1593 bytes
"brian (b.c.) white" <bcwhite@bnr.ca> wrote:
>Does the STL define the case where a container is modified while
>iterating through it?

Yes. In general "all iterators are invalidated
by insertion or deletion". However, it depends
on the container. 

For example, for a list,
the ONLY operation that can stuff things up
is deleting an element to which another
iterator points. (Make sure you don't cache
list.end())

For a vector, if you say "reserve(enough_space)"
you can do whatever would work for an array of
enough_space elements.

-- 
John Max Skaller               voice: 61-2-566-2189
81 Glebe Point Rd              fax:   61-2-660-0850
GLEBE NSW 2037                 email: maxtal@suphys.physics.oz.au
AUSTRALIA                      email: skaller@maxtal.com.au
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <47qo5p$f48@oznet03.ozemail.com.au>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <47l8qe$9fk@bcarh8ab.bnr.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 08 Nov 95 17:25:52 GMT
Approved: fjh@cs.mu.oz.au
From: John Max Skaller <maxtal@suphys.physics.su.oz.au>
Newsgroups: comp.std.c++
Subject: Re: Modifying STL containers via an iterator
X-Original-Date: 8 Nov 1995 17:08:09 GMT
Organization: MAXTAL
Message-ID: <47qo5p$f48@oznet03.ozemail.com.au>
References: <47l8qe$9fk@bcarh8ab.bnr.ca>
X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMKDoO+EDnX0m9pzZAQG5VwF9HLQ0fLzyERpjVn+aZ0UFO3g1Am7UNpyJ
 yLhtX6rgVW8jqvMERhI8tDPXOe5Vo/TY
 =18/+