Home | Projects | Notes > C++ Programming > Container Adaptor - std::priority_queue

Container Adaptor - std::priority_queue

 

std::priority_queue

Initialization

Because std::queue is a container adaptor, you have the flexibility to specify the underlying container—such as deque — at the time of priority queue creation.

L2: std::less<int> makes it a max-heap.

Priority Queue Operations

For more information, see cppreference.com.

OperationBehavior
push()Insert an element in sorted order.
pop()Remove the top element (highest priority; by default greatest).
top()Access the top element (highest priority; by default greatest).
empty()Is the priority queue empty?
size()Number of elements in the priority queue .

 

Project: Usage of std::priority_queue