13#ifndef PRIORITY_QUEUE_HPP
14#define PRIORITY_QUEUE_HPP
18#pragma GCC diagnostic ignored "-Warray-bounds"
54template<
class T,
int Size,
class KeyGreater = std::greater<T>>
80 sl_log_error(
"priority_queue",
81 "Cannot insert a new item since the "
82 "max capacity of %d is reached!",
129 if (
const auto it =
erase(
begin()); it ==
nullptr) {
156 while (child <
size()
196 constexpr bool empty() const noexcept
198 return last ==
nullptr;
Priority Queue.
Definition: priority_queue.hpp:56
constexpr size_type size() const noexcept
Definition: priority_queue.hpp:178
constexpr size_type right_index(size_type i) const
Definition: priority_queue.hpp:272
value_type pop_front() noexcept
takes the first item in the queue and returns it. The item is deleted from the queue....
Definition: priority_queue.hpp:122
typename std::decay< T >::type value_type
Definition: priority_queue.hpp:58
constexpr size_type parent_index(size_type i) const
Definition: priority_queue.hpp:262
constexpr iterator begin() noexcept
if queue != empty() it returns a pointer to the beginning of the queue. The item with the highest pri...
Definition: priority_queue.hpp:207
constexpr iterator end() noexcept
iterator that points past the last element in the queue.
Definition: priority_queue.hpp:217
constexpr void clear() noexcept
remove all items from the queue.
Definition: priority_queue.hpp:255
void init_iterators()
Definition: priority_queue.hpp:288
value_type * iterator
Definition: priority_queue.hpp:59
constexpr const_iterator end() const noexcept
iterator that points past the last element in the queue.
Definition: priority_queue.hpp:241
constexpr priority_queue()=default
value_type elements[Size]
Definition: priority_queue.hpp:294
iterator last
Definition: priority_queue.hpp:295
constexpr size_type left_index(size_type i) const
Definition: priority_queue.hpp:267
int size_type
Definition: priority_queue.hpp:61
iterator first
Definition: priority_queue.hpp:296
constexpr const_iterator begin() const noexcept
if queue != empty() it returns a pointer to the beginning of the queue. The item with the highest pri...
Definition: priority_queue.hpp:231
constexpr bool empty() const noexcept
returns if the queue is empty. in this case both begin() and end() point to nullptr
Definition: priority_queue.hpp:196
constexpr size_type max_size() const noexcept
Definition: priority_queue.hpp:186
iterator erase(const_iterator iterator)
removes an item from the queue by iterator. Performance: O(log n)
Definition: priority_queue.hpp:147
bool insert(value_type &&item) noexcept
inserts a value into the queue. inserts are ordered by their priority. this function takes O(log n) t...
Definition: priority_queue.hpp:75
const value_type * const_iterator
Definition: priority_queue.hpp:60
constexpr size_type biggest_child(size_type current) const
Definition: priority_queue.hpp:277