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::Stack< T, kCapacity > Class Template Reference

Fixed-size stack implementation. More...

#include <Stack.h>

Public Member Functions

PBAT_HOST_DEVICE Stack ()
 Construct empty Stack.
 
PBAT_HOST_DEVICE void Push (T value)
 Add element to the stack.
 
PBAT_HOST_DEVICE T Pop ()
 Remove the top element from the stack.
 
PBAT_HOST_DEVICE T const & Top () const
 Get the top element of the stack.
 
PBAT_HOST_DEVICE auto Size () const
 Get the number of elements in the stack.
 
PBAT_HOST_DEVICE bool IsEmpty () const
 Check if the stack is empty.
 
PBAT_HOST_DEVICE bool IsFull () const
 Check if the stack is full.
 
PBAT_HOST_DEVICE void Clear ()
 Clear the stack.
 
PBAT_HOST_DEVICE T & operator[] (auto i)
 Access element at index i.
 
PBAT_HOST_DEVICE T const & operator[] (auto i) const
 Read-only access element at index i.
 
PBAT_HOST_DEVICE T * begin ()
 Pointer to the beginning of the stack.
 
PBAT_HOST_DEVICE T * end ()
 Pointer to the end of the stack.
 

Detailed Description

template<class T, auto kCapacity = 64>
class pbat::common::Stack< T, kCapacity >

Fixed-size stack implementation.

Template Parameters
TType of the elements in the stack
kCapacityMaximum number of elements in the stack

Member Function Documentation

◆ begin()

template<class T, auto kCapacity = 64>
PBAT_HOST_DEVICE T * pbat::common::Stack< T, kCapacity >::begin ( )
inline

Pointer to the beginning of the stack.

Returns
Pointer to the beginning of the stack

◆ end()

template<class T, auto kCapacity = 64>
PBAT_HOST_DEVICE T * pbat::common::Stack< T, kCapacity >::end ( )
inline

Pointer to the end of the stack.

Returns
Pointer to the end of the stack

◆ IsEmpty()

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

Check if the stack is empty.

Returns
true If the stack is empty

◆ IsFull()

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

Check if the stack is full.

Returns
true If the stack is full

◆ operator[]() [1/2]

template<class T, auto kCapacity = 64>
PBAT_HOST_DEVICE T & pbat::common::Stack< T, kCapacity >::operator[] ( auto i)
inline

Access element at index i.

Note
No bounds checking
Precondition
i < size and i >= 0
Parameters
iIndex of the element
Returns
Reference to the element at index i

◆ operator[]() [2/2]

template<class T, auto kCapacity = 64>
PBAT_HOST_DEVICE T const & pbat::common::Stack< T, kCapacity >::operator[] ( auto i) const
inline

Read-only access element at index i.

Note
No bounds checking
Precondition
i < size and i >= 0
Parameters
iIndex of the element
Returns
Reference to the element at index i

◆ Pop()

template<class T, auto kCapacity = 64>
PBAT_HOST_DEVICE T pbat::common::Stack< T, kCapacity >::Pop ( )
inline

Remove the top element from the stack.

Returns
Top element of the stack

◆ Push()

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

Add element to the stack.

Parameters
valueElement to add

◆ Size()

template<class T, auto kCapacity = 64>
PBAT_HOST_DEVICE auto pbat::common::Stack< T, kCapacity >::Size ( ) const
inline

Get the number of elements in the stack.

Returns
Number of elements in the stack

◆ Top()

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

Get the top element of the stack.

Returns
Top element of the stack

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