Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::internal::StaticMinHeap< T, Capacity, Compare > Class Template Reference

Fixed-capacity statically-allocated binary min-heap. Zero dynamic heap allocations. More...

#include <StaticMinHeap.hpp>

+ Inheritance diagram for corium::internal::StaticMinHeap< T, Capacity, Compare >:
+ Collaboration diagram for corium::internal::StaticMinHeap< T, Capacity, Compare >:

Public Member Functions

void clear () noexcept
 Clear all elements.
 
const T * data () const noexcept
 Direct const access to underlying data array.
 
T * data () noexcept
 Direct access to underlying data array.
 
constexpr bool empty () const noexcept
 Check if heap is empty.
 
constexpr bool full () const noexcept
 Check if heap is full.
 
bool pop () noexcept
 Remove the top element from the heap.
 
template<typename U >
bool push (U &&value)
 Push an element into the heap.
 
void siftDown (std::size_t index) noexcept
 Sift down an element at specified index (e.g. after in-place modification).
 
void siftUp (std::size_t index) noexcept
 Sift up an element at specified index.
 
constexpr std::size_t size () const noexcept
 Current number of elements in the heap.
 
constexpr StaticMinHeap ()=default
 
const T & top () const noexcept
 Access top element.
 
T & top () noexcept
 Access mutable top element.
 

Static Public Member Functions

static constexpr std::size_t capacity () noexcept
 Maximum capacity of the heap.
 

Detailed Description

template<typename T, std::size_t Capacity, typename Compare = std::greater<T>>
class corium::internal::StaticMinHeap< T, Capacity, Compare >

Fixed-capacity statically-allocated binary min-heap. Zero dynamic heap allocations.

Template Parameters
TElement type stored in the heap.
CapacityMaximum number of elements.
CompareComparator predicate (std::greater<T> for min-heap where smallest element is at top).

Constructor & Destructor Documentation

◆ StaticMinHeap()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
constexpr corium::internal::StaticMinHeap< T, Capacity, Compare >::StaticMinHeap ( )
constexprdefault

Member Function Documentation

◆ capacity()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
static constexpr std::size_t corium::internal::StaticMinHeap< T, Capacity, Compare >::capacity ( )
inlinestaticconstexprnoexcept

Maximum capacity of the heap.

◆ clear()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
void corium::internal::StaticMinHeap< T, Capacity, Compare >::clear ( )
inlinenoexcept

Clear all elements.

◆ data() [1/2]

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
const T * corium::internal::StaticMinHeap< T, Capacity, Compare >::data ( ) const
inlinenoexcept

Direct const access to underlying data array.

◆ data() [2/2]

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
T * corium::internal::StaticMinHeap< T, Capacity, Compare >::data ( )
inlinenoexcept

Direct access to underlying data array.

◆ empty()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
constexpr bool corium::internal::StaticMinHeap< T, Capacity, Compare >::empty ( ) const
inlineconstexprnoexcept

Check if heap is empty.

◆ full()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
constexpr bool corium::internal::StaticMinHeap< T, Capacity, Compare >::full ( ) const
inlineconstexprnoexcept

Check if heap is full.

◆ pop()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
bool corium::internal::StaticMinHeap< T, Capacity, Compare >::pop ( )
inlinenoexcept

Remove the top element from the heap.

Returns
true if popped, false if heap was empty.
+ Here is the call graph for this function:

◆ push()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
template<typename U >
bool corium::internal::StaticMinHeap< T, Capacity, Compare >::push ( U &&  value)
inline

Push an element into the heap.

Returns
true if pushed, false if capacity exceeded.
+ Here is the call graph for this function:

◆ siftDown()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
void corium::internal::StaticMinHeap< T, Capacity, Compare >::siftDown ( std::size_t  index)
inlinenoexcept

Sift down an element at specified index (e.g. after in-place modification).

+ Here is the caller graph for this function:

◆ siftUp()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
void corium::internal::StaticMinHeap< T, Capacity, Compare >::siftUp ( std::size_t  index)
inlinenoexcept

Sift up an element at specified index.

+ Here is the caller graph for this function:

◆ size()

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
constexpr std::size_t corium::internal::StaticMinHeap< T, Capacity, Compare >::size ( ) const
inlineconstexprnoexcept

Current number of elements in the heap.

◆ top() [1/2]

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
const T & corium::internal::StaticMinHeap< T, Capacity, Compare >::top ( ) const
inlinenoexcept

Access top element.

◆ top() [2/2]

template<typename T , std::size_t Capacity, typename Compare = std::greater<T>>
T & corium::internal::StaticMinHeap< T, Capacity, Compare >::top ( )
inlinenoexcept

Access mutable top element.


The documentation for this class was generated from the following file: