Jump to content
  • Advertisement

Archived

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

gimp

Erasing the front of a std::vector..memcpy?

This topic is 6197 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

If I erased the front of a vector what the chance that it''ll just move the pointer forward and release the ram I erased rather than memcopy all the following data back to .begin() Chris Brodie http:\\fourth.flipcode.com

Share this post


Link to post
Share on other sites
Advertisement
IIRC it will memcpy everything to the beginning of the vector.

You might want to use a deque (double ended queue). Then it will only 'advance a pointer' if you remove stuff at the beginning (it won't free the memory though, it will keep the memory if you want to add stuff to the front of the deque later).

A deque reserves a little extra space both before and after the actual data, but it must still realloc and memcpy when it gets full, so it's very similar to a vector, only that both the front and the end work in the same way. The downside is somewhat more costly accesses than a vector (due to adding the index of the first deque element to the index you want to access).

Edited by - Dactylos on July 31, 2001 7:26:24 AM

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!