Jump to content
  • Advertisement

Archived

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

The C modest god

Priority queue

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

Advertisement
The standard priority queue is a container adapter, not a container, so you need a container inside it to hold the elements. So you use a deque or a vector, or a list.

Share this post


Link to post
Share on other sites
From what I have seen you can implement a priority queue with an almost complete binary tree.
I dont see how the vector fits in, and actually I dont know what is the format of a vector? what kind of data type is a vector?
From what I know about vectors, they contain a number of coordinates of a certain field.

Share this post


Link to post
Share on other sites
Why there is no makeheap in priority queue? It does make heap every time an object is pushed into it?
How do I set the priority queue in a way that the minimal obhect is the top?

Share this post


Link to post
Share on other sites
Priority queue uses
std::make_heap
to create the heap, and then
std::push_heap
and
std::pop_heap
to push and pop elements into it. So
std::priority_queue 
will use the push() member to push_back the element into the vector/deque/list, and then call the push_heap algorithm on the vector. You can pass the sorting criteria in as a constructor parameter, or use the template parameter.




[edited by - Jingo on May 25, 2004 5:38:28 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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!