template<typename K, typename V, template<typename> class HeapFunc = MaxHeap>
bpf::collection::PriorityQueue class

Template parameters
K the key type
V the value type
HeapFunc heap comparision operator usually set to either MaxHeap or MinHeap

Priority queue implemented using min/max heap

Public types

struct Entry

Constructors, destructors, conversion operators

PriorityQueue(fsize maxsize = 0) explicit
PriorityQueue(const std::initializer_list<Entry>& lst)
PriorityQueue(const PriorityQueue<K, V, HeapFunc>& other)
PriorityQueue(PriorityQueue<K, V, HeapFunc>&& other) noexcept

Public functions

auto operator=(const PriorityQueue<K, V, HeapFunc>& other) -> PriorityQueue<K, V, HeapFunc>&
auto operator=(PriorityQueue<K, V, HeapFunc>&& other) -> PriorityQueue<K, V, HeapFunc>& noexcept
void Clear()
void Push(const K& key, const V& value)
void Push(const K& key, V&& value)
auto Pop() -> V
auto Top() -> V&
auto Top() const -> const V&
auto Size() const -> fsize

Function documentation

template<typename K, typename V, template<typename> class HeapFunc>
bpf::collection::PriorityQueue<K, V, HeapFunc>::PriorityQueue(fsize maxsize = 0) explicit

Parameters
maxsize maximum size of queue (0 = infinity/unlimited)

Constructs an empty PriorityQueue

template<typename K, typename V, template<typename> class HeapFunc>
bpf::collection::PriorityQueue<K, V, HeapFunc>::PriorityQueue(const std::initializer_list<Entry>& lst)

Parameters
lst the initial list of items to push to this new queue

Constructs a PriorityQueue from an existing initializer list

template<typename K, typename V, template<typename> class HeapFunc>
bpf::collection::PriorityQueue<K, V, HeapFunc>::PriorityQueue(const PriorityQueue<K, V, HeapFunc>& other)

Copy constructor

template<typename K, typename V, template<typename> class HeapFunc>
bpf::collection::PriorityQueue<K, V, HeapFunc>::PriorityQueue(PriorityQueue<K, V, HeapFunc>&& other) noexcept

Move constructor

template<typename K, typename V, template<typename> class HeapFunc>
PriorityQueue<K, V, HeapFunc>& bpf::collection::PriorityQueue<K, V, HeapFunc>::operator=(const PriorityQueue<K, V, HeapFunc>& other)

Copy assignment operator

template<typename K, typename V, template<typename> class HeapFunc>
PriorityQueue<K, V, HeapFunc>& bpf::collection::PriorityQueue<K, V, HeapFunc>::operator=(PriorityQueue<K, V, HeapFunc>&& other) noexcept

Move assignment operator

template<typename K, typename V, template<typename> class HeapFunc>
void bpf::collection::PriorityQueue<K, V, HeapFunc>::Clear()

Clears this queue

template<typename K, typename V, template<typename> class HeapFunc>
void bpf::collection::PriorityQueue<K, V, HeapFunc>::Push(const K& key, const V& value)

Parameters
key the key for that element
value the value for that element

Pushes an element on the queue

template<typename K, typename V, template<typename> class HeapFunc>
void bpf::collection::PriorityQueue<K, V, HeapFunc>::Push(const K& key, V&& value)

Parameters
key the key for that element
value the value for that element

Pushes an element on the queue

template<typename K, typename V, template<typename> class HeapFunc>
V bpf::collection::PriorityQueue<K, V, HeapFunc>::Pop()

Returns the extracted/removed item
Exceptions
IndexException if the queue is empty

Extracts the top of the queue

template<typename K, typename V, template<typename> class HeapFunc>
V& bpf::collection::PriorityQueue<K, V, HeapFunc>::Top()

Returns mutable item
Exceptions
IndexException if the queue is empty

Returns the top of the queue

template<typename K, typename V, template<typename> class HeapFunc>
const V& bpf::collection::PriorityQueue<K, V, HeapFunc>::Top() const

Returns immutable item
Exceptions
IndexException if the queue is empty

Returns the top of the queue

template<typename K, typename V, template<typename> class HeapFunc>
fsize bpf::collection::PriorityQueue<K, V, HeapFunc>::Size() const

Returns number of items as unsigned

Returns the number of items in this queue