Re: need some help with list::end ()
- From: "Abubakar" <emailallrise@xxxxxxxxx>
- Date: Wed, 16 Aug 2006 21:21:19 +0500
Hi,
Ok I'll try the *remove* method of the list and if I still cant get the
begin() method to work right I'll get back to this post.
Regards,
-ab.
"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
wrote in message news:u32vT6TwGHA.3936@xxxxxxxxxxxxxxxxxxxxxxx
Abubakar wrote:as
Sorry for the late reply.
How are you deleting the items? Just doing filenames.erase(filename)
invalidates the iterator to the deleted object.
I use the "remove" method.
I have the following declaration:
list<char * >::const_iterator name, prev;
at some point I do:
prev = name;
name ++;
filenames.remove ( *prev );
and this is how I remove the items.
If you have duplicates in your list, the call to remove will remove more
than one of them at a time, including possibly the one now referenced by
"name". Use the loop that Bo suggested:
if (some_condition)
filename = filenames.erase(filename);
else
++filename;
that's the canonical way to iterate through a list removing some elements
you go.
-cd
.
- References:
- need some help with list::end ()
- From: Abubakar
- Re: need some help with list::end ()
- From: Bo Persson
- Re: need some help with list::end ()
- From: Abubakar
- Re: need some help with list::end ()
- From: Carl Daniel [VC++ MVP]
- need some help with list::end ()
- Prev by Date: Re: need some help with list::end ()
- Next by Date: Re: Unicode characters in identifiers
- Previous by thread: Re: need some help with list::end ()
- Next by thread: executing crt functions in immidiate window
- Index(es):
Relevant Pages
|