Fixed-capacity binary min-heap.
More...
|
|
constexpr auto | empty () const noexcept -> bool |
| | Whether the heap is empty.
|
|
constexpr auto | peek () const noexcept -> T |
| | Peek at the minimum element without removing it.
|
|
template<typename Less> |
| auto | pop (Less less) noexcept -> void |
| | Remove the minimum element.
|
| template<typename Less> |
| auto | push (T elem, Less less) noexcept -> bool |
| | Insert an element, maintaining the heap invariant.
|
| template<typename Less> |
| auto | remove (T elem, Less less) noexcept -> bool |
| | Remove a specific element by linear scan.
|
|
constexpr auto | size () const noexcept -> u32 |
| | Number of elements in the heap.
|
|
|
T | entries [Capacity] {} |
|
u32 | m_count {0} |
template<typename T, u32 Capacity>
struct lib::min_heap< T, Capacity >
Fixed-capacity binary min-heap.
- Template Parameters
-
| T | Element type (typically a pointer). |
| Capacity | Maximum number of elements. |
◆ push()
template<typename T, u32 Capacity>
template<typename Less>
| auto lib::min_heap< T, Capacity >::push |
( |
T | elem, |
|
|
Less | less )->bool |
|
inlinenodiscardexportnoexcept |
Insert an element, maintaining the heap invariant.
- Returns
- true on success, false if the heap is full.
◆ remove()
template<typename T, u32 Capacity>
template<typename Less>
| auto lib::min_heap< T, Capacity >::remove |
( |
T | elem, |
|
|
Less | less )->bool |
|
inlinenodiscardexportnoexcept |
Remove a specific element by linear scan.
- Returns
- true if the element was found and removed.
The documentation for this struct was generated from the following file: