![]() |
Shamrock 2025.10.0
Astrophysical Code
|
Fixed-capacity stack container with compile-time size determination. More...
#include <shambase/include/shambase/FixedStack.hpp>
Collaboration diagram for shambase::FixedStack< T, stack_size >:Public Member Functions | |
| constexpr | FixedStack () |
| Default constructor creating an empty stack. | |
| constexpr | FixedStack (const T &val) |
| Constructor creating a stack with one initial element. | |
| constexpr bool | is_not_empty () const |
| Check if the stack contains any elements. | |
| constexpr bool | empty () const |
| Check if the stack is empty. | |
| constexpr u32 | size () const |
| Returns the number of elements in the stack. | |
| void | push (const T &val) |
| Push an element onto the top of the stack. | |
| T & | top () |
| Access the top element. | |
| constexpr const T & | top () const |
| Access the top element (const version) | |
| constexpr void | pop () |
| Remove the top element from the stack. | |
| T | pop_ret () |
| Remove and return the top element from the stack. | |
Public Attributes | |
| T | id_stack [stack_size] |
| Storage array for stack elements. | |
| u32 | stack_cursor |
| Cursor pointing to the next available slot (stack_size = empty, 0 = full) | |
Fixed-capacity stack container with compile-time size determination.
A high-performance stack implementation that uses a statically allocated array for storage. The stack capacity is determined at compile time, eliminating runtime memory allocation overhead. The implementation uses a cursor-based approach where the cursor points to the next available slot in the stack array.
The stack grows downward in memory (decreasing indices), with the cursor starting at stack_size (empty stack) and decreasing as elements are pushed. This design choice optimizes for common usage patterns in computational algorithms.
| T | Element type to store in the stack |
| stack_size | Maximum number of elements the stack can hold |
Definition at line 88 of file FixedStack.hpp.
|
inlineconstexpr |
Default constructor creating an empty stack.
Definition at line 104 of file FixedStack.hpp.
|
inlineconstexpr |
Constructor creating a stack with one initial element.
Definition at line 107 of file FixedStack.hpp.
|
inlineconstexpr |
Check if the stack is empty.
Definition at line 115 of file FixedStack.hpp.
Here is the call graph for this function:
|
inlineconstexpr |
Check if the stack contains any elements.
Definition at line 112 of file FixedStack.hpp.
Here is the call graph for this function:
|
inlineconstexpr |
Remove the top element from the stack.
Definition at line 143 of file FixedStack.hpp.
Here is the call graph for this function:
|
inline |
Remove and return the top element from the stack.
Definition at line 153 of file FixedStack.hpp.
Here is the call graph for this function:
|
inline |
Push an element onto the top of the stack.
Definition at line 121 of file FixedStack.hpp.
|
inlineconstexpr |
Returns the number of elements in the stack.
Definition at line 118 of file FixedStack.hpp.
Here is the call graph for this function:
|
inline |
Access the top element.
Definition at line 131 of file FixedStack.hpp.
Here is the call graph for this function:
|
inlineconstexpr |
Access the top element (const version)
Definition at line 137 of file FixedStack.hpp.
Here is the call graph for this function:| T shambase::FixedStack< T, stack_size >::id_stack[stack_size] |
Storage array for stack elements.
Definition at line 96 of file FixedStack.hpp.
| u32 shambase::FixedStack< T, stack_size >::stack_cursor |
Cursor pointing to the next available slot (stack_size = empty, 0 = full)
Definition at line 98 of file FixedStack.hpp.