20namespace sequoia::data_structures
27 template<
class T, std::
size_t MaxDepth,
class Compare=std::ranges::less>
36 : m_Q{make_Q(l, Compare{})}
41 : m_Q{make_Q(l, compare)}
54 constexpr void push(
const T& val)
57 throw std::logic_error(
"Attempting to exceed max priority_queue depth");
61 bubble_up(m_Q.begin(), m_Q.begin() + m_End - 1, m_Compare);
65 constexpr const T& top()
const noexcept
70 constexpr void pop()
noexcept
72 std::ranges::iter_swap(m_Q.begin(), m_Q.begin() + m_End -1);
74 sequoia::make_heap(m_Q.begin(), m_Q.begin() + m_End, m_Compare);
78 constexpr bool empty()
const noexcept
84 constexpr std::size_t size()
const noexcept
92 return (lhs.m_End == rhs.m_End) && std::ranges::equal(lhs.m_Q.begin(), lhs.m_Q.begin() + lhs.m_End, rhs.m_Q.begin(), rhs.m_Q.begin() + rhs.m_End);
95 std::array<T, MaxDepth> m_Q{};
99 SEQUOIA_NO_UNIQUE_ADDRESS Compare m_Compare;
101 constexpr static std::array<T, MaxDepth> make_Q(std::initializer_list<T> l,
const Compare& compare)
103 auto q{utilities::to_array<T, MaxDepth>(l)};
104 sequoia::make_heap(q.begin(), q.end(), compare);
A collection of constexpr algorithms.
Utility to convert an initializer_list into an array, potentially transforming the initializer_list i...
A priority_queue suitable for constexpr contexts.
Definition: StaticPriorityQueue.hpp:29