ZXFoundation™ 26h2
Loading...
Searching...
No Matches
lib::min_heap< T, Capacity > Struct Template Referenceexport

Fixed-capacity binary min-heap. More...

Collaboration diagram for lib::min_heap< T, Capacity >:
[legend]

Public Member Functions

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.

Data Fields

entries [Capacity] {}
u32 m_count {0}

Detailed Description

template<typename T, u32 Capacity>
struct lib::min_heap< T, Capacity >

Fixed-capacity binary min-heap.

Template Parameters
TElement type (typically a pointer).
CapacityMaximum number of elements.

Member Function Documentation

◆ 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: