Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

EGD Eric

removing elements from a list with an iterator, then placing it into another list.

This topic is 5300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the enginuity articles, Richard removes dead objects from the liveObjects list and adds them to the deadObjects list like this: liveObjects.remove(this); deadObjects.push_back(this); But he says that remove is inneficient, because it searches the whole list for the object before removing it. He says that using an iterator would be more efficient. Which function uses an iterator to remove items? The only one I've found is erase . And that one deallocates memory for the pointer as well. That won't do, because I need to remove the item from one list and put it into another list. [edited by - EGD Eric on April 15, 2004 1:20:18 PM]

Share this post


Link to post
Share on other sites
Advertisement
erase does not deallocate memory from your pointers if its a list of pointer.(imagine how useless it would be if you had a list of nullpointers, or a list of invalid pointers)

Maybe the documentation meant that it deallocated memory for the node being erased.

Share this post


Link to post
Share on other sites
yes, erase() does not perform delete on the contents, just junks the node. If you thought that it did, i''ll bet you''ve got some real dandy memory leaks in there somewhere :-)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!