PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
pbat::common::Heap< T, Less, kCapacity > Class Template Reference

Fixed-size max heap. More...

#include <Heap.h>

Public Member Functions

PBAT_HOST_DEVICE Heap (Less _less=Less{})
 Construct a new Heap object.
 
PBAT_HOST_DEVICE void Push (T value)
 Push an element to the heap.
 
PBAT_HOST_DEVICE T Pop ()
 Pop the top element from the heap.
 
PBAT_HOST_DEVICE T const & Top () const
 Get the top element of the heap.
 
PBAT_HOST_DEVICE auto Size () const
 Get the size of the heap.
 
PBAT_HOST_DEVICE bool IsEmpty () const
 Check if the heap is empty.
 
PBAT_HOST_DEVICE bool IsFull () const
 Check if the heap is full.
 

Detailed Description

template<class T, class Less = std::less<T>, auto kCapacity = 64>
class pbat::common::Heap< T, Less, kCapacity >

Fixed-size max heap.

Template Parameters
TType of the elements
LessLess-than comparator
kCapacityCapacity of the heap

Constructor & Destructor Documentation

◆ Heap()

template<class T, class Less = std::less<T>, auto kCapacity = 64>
PBAT_HOST_DEVICE pbat::common::Heap< T, Less, kCapacity >::Heap ( Less _less = Less{})
inline

Construct a new Heap object.

Parameters
_lessComparator for the heap

Member Function Documentation

◆ IsEmpty()

template<class T, class Less = std::less<T>, auto kCapacity = 64>
PBAT_HOST_DEVICE bool pbat::common::Heap< T, Less, kCapacity >::IsEmpty ( ) const
inline

Check if the heap is empty.

Returns
true if the heap is empty, false otherwise

◆ IsFull()

template<class T, class Less = std::less<T>, auto kCapacity = 64>
PBAT_HOST_DEVICE bool pbat::common::Heap< T, Less, kCapacity >::IsFull ( ) const
inline

Check if the heap is full.

Returns
true if the heap is full, false otherwise

◆ Pop()

template<class T, class Less = std::less<T>, auto kCapacity = 64>
PBAT_HOST_DEVICE T pbat::common::Heap< T, Less, kCapacity >::Pop ( )
inline

Pop the top element from the heap.

Returns
Top element

◆ Push()

template<class T, class Less = std::less<T>, auto kCapacity = 64>
PBAT_HOST_DEVICE void pbat::common::Heap< T, Less, kCapacity >::Push ( T value)
inline

Push an element to the heap.

Parameters
valueElement to push

◆ Size()

template<class T, class Less = std::less<T>, auto kCapacity = 64>
PBAT_HOST_DEVICE auto pbat::common::Heap< T, Less, kCapacity >::Size ( ) const
inline

Get the size of the heap.

Returns
Size of the heap

◆ Top()

template<class T, class Less = std::less<T>, auto kCapacity = 64>
PBAT_HOST_DEVICE T const & pbat::common::Heap< T, Less, kCapacity >::Top ( ) const
inline

Get the top element of the heap.

Returns
Top element

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