Archived

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

gimp

Move element to front in std::vector ?

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
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