Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualOlof Hedman

Posted 15 May 2012 - 03:55 AM

I don't use STL because I never figured out how to delete from a list while iterating through, so I made my own classes for List<>, Array<>, and Map<>


Update your iterator with the one that is returned by erase, and it should work fine.
it = collection.erase(it);

Just out of curiousity, how does your container handle it?
For example the fact that "bcount" and "zcount" no longer is valid after you "Remove".
Also, how does it handle that the index will "skip" one element when you erase?

#2Olof Hedman

Posted 15 May 2012 - 03:54 AM

I don't use STL because I never figured out how to delete from a list while iterating through, so I made my own classes for List<>, Array<>, and Map<>


Just update your iterator with the one that is returned by erase, and it should work fine.
it = collection.erase(it);

Just out of curiousity, how does your container handle it?
For example the fact that "bcount" and "zcount" no longer is valid after you "Remove".
Also, how does it handle that the index will "skip" one element when you erase?

#1Olof Hedman

Posted 15 May 2012 - 03:50 AM

I don't use STL because I never figured out how to delete from a list while iterating through, so I made my own classes for List<>, Array<>, and Map<>


Just update your iterator with the one that is returned by erase, and it should work fine.
it = collection.erase(it);

PARTNERS