Priority queue
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.
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.
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.
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?
How do I set the priority queue in a way that the minimal obhect is the top?
Priority queue uses
[edited by - Jingo on May 25, 2004 5:38:28 AM]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement