The STL priority_queue is a container adapter that represents a collection of elements where only the largest element, determined by some comparison functor, can be accessed. Internally, the priority_queue is built on top of a heap using the heap algorithms make_heap, push_heap, and pop_heap.
priority_queue is a container adapter, not a true STL container, and is implemented in terms of another linear container class like vector or deque. To explicitly specify which container to use in the priority_queue, parametrize the priority_queue as priority_queue<T, ContainerType<T> >.
By default, the priority_queue sorts elements using the < operator. To change this behavior, parametrize the priority_queue as priority_queue<T, ContainerType<T>, ComparisonFunctor>. Note that you must specify the underlying container type in addition to the comparison functor class.
Enqueues a new element into the priority_queue.
Dequeues the maximal element of the priority_queue. The behavior is undefined if the priority_queue has no elements, so be sure not to pop off of an empty priority_queue. Note that pop does not return a value; use top to get the value before popping.
Returns the maximal element of the priority_queue (the one that will be removed by pop). The behavior is undefined if the priority_queue has no elements, so be sure not to access the front element of an empty priority_queue.
Returns the number of elements stored in the priority_queue.
Returns whether the priority_queue is empty. It's considered good practice to call empty to determine whether the priority_queue is empty rather than checking whether size() returns zero.
priority_queue with specified elementsConstructs a new priority_queue whose contents are equal to the elements specified in the iterator range. The input range need not be sorted.