A
Arne Claus
Hi
If've just read, that remove() on a list does not actually remove the
elements, but places them at the end of the list (according to TC++STL
by Josuttis). It also says, that remove returns a new, logical end
pointer, so that the following
myList::iterator end = myListObj.remove(myInt);
myListObj.erase(end, myListObj.end());
is possible and removes the "invalid" items at the end of the list.
Now my question - is the following statement still vaild?
myList::iterator end = myListObj.remove(myInt);
myListObj.insert(anotherInt);
myListObj.erase(end, myListObj.end());
or does the iterator "end" not change?
In my actual code I do some deleting and inserting after reusing the
list (iterating over all elements). So I would like to do some kind of
"lazy" correcting, which means doing the "erase-step" just before I
start iterating over all elements again.
Thanks
Arne
If've just read, that remove() on a list does not actually remove the
elements, but places them at the end of the list (according to TC++STL
by Josuttis). It also says, that remove returns a new, logical end
pointer, so that the following
myList::iterator end = myListObj.remove(myInt);
myListObj.erase(end, myListObj.end());
is possible and removes the "invalid" items at the end of the list.
Now my question - is the following statement still vaild?
myList::iterator end = myListObj.remove(myInt);
myListObj.insert(anotherInt);
myListObj.erase(end, myListObj.end());
or does the iterator "end" not change?
In my actual code I do some deleting and inserting after reusing the
list (iterating over all elements). So I would like to do some kind of
"lazy" correcting, which means doing the "erase-step" just before I
start iterating over all elements again.
Thanks
Arne