Priority queue

Started by
3 comments, last by The C modest god 19 years, 11 months ago
What is the purpose of vector in the priority queue?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
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.
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.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
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?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
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]

This topic is closed to new replies.

Advertisement