Heap

header <queue>

Use priority_queue in C++ as heap

template<
    class T,
    class Container = std::vector<T>,
    class Compare = std::less<typename Container::value_type>
> class priority_queue;

By default is Max heap,

priority_queue<int, vector<int>, greater<int> > is Min heap.

Operations

push(x)
pop()
top()
size()
empty()

results matching ""

    No results matching ""