Skip to content

num::indexed_priority_queue

Defined in header <structures/containers/indexed_priority_queue.hpp>

template <typename Key = double, std::integral Index = num::idx,
          typename Compare = std::less<Key>>
class indexed_priority_queue;

Priority queue of indices in [0, capacity): push, pop and update in \(O(\log n)\). comp(a, b) true means a has priority; the default is a min-heap.

Members

member description
using key_type = Key
using index_type = Index
using compare_type = Compare
explicit indexed_priority_queue(Index capacity = 0, Compare comp = Compare{}) Construct an empty queue for indices below capacity.
void push(Index index, const Key &key) Insert index with key.
void pop() Remove the top element.
Index top_index() const Return the index of the top element.
const Key &top_key() const Return the key of the top element.
bool contains(Index index) const noexcept Test whether index is in the queue.
const Key &key_of(Index index) const Return the key of index.
void update(Index index, const Key &new_key) Set the key of index.
void improve_key(Index index, const Key &new_key) Raise the priority of index to a new key.
void erase(Index index) Remove index.
bool empty() const noexcept Test whether the queue is empty.
Index size() const noexcept Return the number of items in the queue.
Index capacity() const noexcept Return the capacity.
void clear() noexcept Remove every item.