A
Alan
I was wondering whether it is good programming practice or asking
for trouble to modify a vector while iterating through it. That is, I
want to do something like the following pseudocode in C++:
for each element of the vector
for each subsequent element of the vector
if the belong together <some code to compare them>
then merge the elements (add the 2nd to the 1st, then
delete the 1st)
Does deleting an element before reaching it in the iteration mess up
the indexing and/or size of the vector, or do C++ compilers handle
this fine?
Thanks, Alan
for trouble to modify a vector while iterating through it. That is, I
want to do something like the following pseudocode in C++:
for each element of the vector
for each subsequent element of the vector
if the belong together <some code to compare them>
then merge the elements (add the 2nd to the 1st, then
delete the 1st)
Does deleting an element before reaching it in the iteration mess up
the indexing and/or size of the vector, or do C++ compilers handle
this fine?
Thanks, Alan