Archived

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

The C modest god

Priority queue

Recommended Posts

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