C++ STL priority queues
i wanted to implement piority queues using c++ stl....
i want to extract both min and max elemnts (compute with the extracted value as well a s pop them out of queue)
i am able to pop the largest since front elemnet is largest...
well i want to pop the smallest elemnts as well..i also want the samallest and largest elemnt to be stored in a temp variable so as to compute sumthng else...
can u guide me on how do i do it here
Re: C++ STL priority queues
I guess we can't delete the smaller value.. but while creating a priority_queue if we create using greater<int> then we can delete small value, but we can't delete higher value..
For the second question can we try somthing like this..
int i, j;
j = p.top();
so that q remains like that and p will be deleted by the end..
I am not sure how much it will work.. so thought to give my thoughts to start the discussion..
If it is not manditory to take a priority_queue we can take vector instead of that..
|All times are GMT +5.5. The time now is 16:31.|