Sorting vectors or other containers

Started by
0 comments, last by Laroche 21 years, 1 month ago
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.
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Advertisement
Try these containers:

  std::mapstd::priority_queue  

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

This topic is closed to new replies.

Advertisement