I have a problem with stl priority queue.I want to have the priority queue in the increasing order,which is decreasing by default.Is there any way to do this in priority qu
Use a different comparator as the 3rd template argument of std::priority_queue
.
priority_queue is a container adaptor that works on any sequence you define. The performance of insertion is equal to the std::push_heap
operation and takes logarithmic time. So the complexity to sorting after all insertions are done isn't equal. If you insert a fixed amount and work the queue afterwards a vector
and a single sort
could be more efficient.