0

I have a question regarding the implementation of priority_queue container adaptor. Now, I know it internally uses the push_heap, pop_heap functions. This is my question:

make_heap turns a vector into a heap in O(n) time by utilizing the heapify algorithm. Is there a similar heapify operation for priority queues in C++ STL? The only possible way of populating a priority_queue that I know of is by manually adding elements. Is there a method for batch insert also in C++ STL for priority_queue. I couldn't find anything on the C++ reference page.

Manav Garg
  • 512
  • 1
  • 3
  • 17

1 Answers1

0

Why just don't use std::priority_queue ?

http://www.cplusplus.com/reference/queue/priority_queue/

It does all insert/delete operations automatically. So you don't need to worry about keeping your container in priority queue order.

  • I am using std::priority_queue only. What I wanted to know was whether there was a method for batch insert as inserting in a batch can be done in linear time using heapify algorithm. – Manav Garg Jan 09 '16 at 21:26