Jump to content
  • Advertisement

Archived

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

gimp

Move element to front in std::vector ?

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

I have a vector of windows. When it comes time to render the windows I''d like them to be rendered in order of who was on top most ecently. To do this I''d like to move the window(pointer) that has focus to the top of the vector. Is there a simple way of doing this. Currently I copy the pointer out to a temp variable, then erase the current one, then insert it back at the front. Is there a better way? Many thanks

Share this post


Link to post
Share on other sites
Advertisement
Yup, use a list instead. Inserting/Erasing things from anywhere but the end of a vector is inefficient. Doing so at the beginning is the worst thing you can do.

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!