Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::TArrayHeap< T, N, IsLess > Class Template Referencefinal

A fixed size heap backed by an array. The container inherits the properties of a fixed size array of type T. The container keeps all N elements alive until its lifetime ends, even if elements are popped/removed from the stack. It is guaranteed that no dynamic memory allocation takes place. More...

#include <TArrayHeap.h>

Public Member Functions

 TArrayHeap ()
 
 TArrayHeap (IsLess isLess)
 
template<typename U >
void push (U &&item)
 Adds an item to the heap. The item originally at the target index will be overwritten.
 
void pop ()
 Removes the top item from the heap. The item originally at the target index is still alive after this call.
 
std::size_t size () const
 
void clear ()
 
bool isEmpty () const
 
T & top ()
 Access the top item of the heap. By default, the top item is the maximum item (max heap). If the comparator is reversed, e.g., comparing using operator >, then the top item is the minimum item (min heap).
 
const T & top () const
 

Detailed Description

template<typename T, std::size_t N, typename IsLess = std::less<T>>
class ph::TArrayHeap< T, N, IsLess >

A fixed size heap backed by an array. The container inherits the properties of a fixed size array of type T. The container keeps all N elements alive until its lifetime ends, even if elements are popped/removed from the stack. It is guaranteed that no dynamic memory allocation takes place.

Template Parameters
TType of the array element.
NMaximum size of the backing array.
IsLessComparator for the array element. The default comparator makes this heap a max heap.

Constructor & Destructor Documentation

◆ TArrayHeap() [1/2]

template<typename T , std::size_t N, typename IsLess >
requires std::default_initializable<IsLess>
ph::TArrayHeap< T, N, IsLess >::TArrayHeap ( )
inline

Creates empty heap.

◆ TArrayHeap() [2/2]

template<typename T , std::size_t N, typename IsLess >
ph::TArrayHeap< T, N, IsLess >::TArrayHeap ( IsLess isLess)
inlineexplicit

Creates empty heap with user-provided comparator.

Member Function Documentation

◆ clear()

template<typename T , std::size_t N, typename IsLess >
void ph::TArrayHeap< T, N, IsLess >::clear ( )
inline

◆ isEmpty()

template<typename T , std::size_t N, typename IsLess >
bool ph::TArrayHeap< T, N, IsLess >::isEmpty ( ) const
inline

◆ pop()

template<typename T , std::size_t N, typename IsLess >
void ph::TArrayHeap< T, N, IsLess >::pop ( )
inline

Removes the top item from the heap. The item originally at the target index is still alive after this call.

◆ push()

template<typename T , std::size_t N, typename IsLess >
template<typename U >
void ph::TArrayHeap< T, N, IsLess >::push ( U && item)
inline

Adds an item to the heap. The item originally at the target index will be overwritten.

◆ size()

template<typename T , std::size_t N, typename IsLess >
std::size_t ph::TArrayHeap< T, N, IsLess >::size ( ) const
inline

◆ top() [1/2]

template<typename T , std::size_t N, typename IsLess >
T & ph::TArrayHeap< T, N, IsLess >::top ( )
inline

Access the top item of the heap. By default, the top item is the maximum item (max heap). If the comparator is reversed, e.g., comparing using operator >, then the top item is the minimum item (min heap).

◆ top() [2/2]

template<typename T , std::size_t N, typename IsLess >
const T & ph::TArrayHeap< T, N, IsLess >::top ( ) const
inline

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