C++ STL priority queue
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.
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.
链接地址: http://www.djcxy.com/p/63834.html上一篇: 如何使用STL实现Prim的算法?
下一篇: C ++ STL优先级队列