Jump to content
  • Advertisement


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


Sorting vectors or other containers

This topic is 5620 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 which recieves many insertion and removal requests. The method which uses the vector needs to have it sorted, but I''m not sure exactly how to do this. I''ve looked through SGI documentation of the STL but I have trouble finding exactly what it is I want. Actually, thinking about it, maybe vector is not suited for what I need. I need a container which will sort the objects upon insertion. Which one does this? Unfortunately I dont have any data-structure books at home (its next on my shopping list), so I''m not very knowledgeable in this area.

Share this post

Link to post
Share on other sites
Try these containers:


The latter seems to fit your description best, but you only ever have access to the first element in the controlled sequence through the "top" member function. It's not too hard to roll your own, less restrictive, priority queue on top of a vector, list or deque.

Edit: stupid smilies.

[edited by - Kippesoep on March 2, 2003 5:16:41 PM]

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!