A C++ template library for embedded applications
MIT licensed
Designed and
maintained by
John Wellbelove

intrusive_stack


An intrusive stack.
STL equivalent: std::stack

etl::intrusive_stack<typename TValue, typename TLink>

TValue is the type that contains the actual values. It is derived from Tlink.
Tlink is the link type for this list. It must contain an etl_next pointer member.
See Intrusive links.

____________________________________________________________________________________________________

Member types


link_type       TLink
value_type      TValue
size_type       std::size_t
pointer         value_type*
const_pointer   const value_type*
reference       value_type&
const_reference const value_type&

____________________________________________________________________________________________________

Constructor


etl::stack<typename T, const size_t SIZE>();

Default constructs SIZE elements.

____________________________________________________________________________________________________

Element access


reference top()
const_reference top() const

Returns a reference or const reference to the element at the top of the stack.

____________________________________________________________________________________________________

Capacity


bool empty() const

Returns true if the size of the stack is zero, otherwise false.
____________________________________________________________________________________________________

bool full() const

Returns true if the size of the stack is SIZE, otherwise false.
____________________________________________________________________________________________________

size_t size() const

Returns the size of the stack.
____________________________________________________________________________________________________

size_t available() const

Returns the remaining available capacity in the stack.
____________________________________________________________________________________________________

size_t max_size() const

Returns the maximum possible size of the stack.
____________________________________________________________________________________________________

size_t capacity() const

Returns the maximum possible size of the stack.

____________________________________________________________________________________________________

Modifiers

void push(link_type& value);

Pushes a value to the top of the stack.
____________________________________________________________________________________________________

void pop();

Pop a value from the top of the stack.
Emits an etl::intrusive_stack_empty if the stack is empty and ETL_CHECK_PUSH_POP is defined.
If asserts or exceptions are not enabled then undefined behaviour occurs.
____________________________________________________________________________________________________

template <typename TContainer>
void pop_into(TContainer& destination);

Pop a value from the top of the stack and push to the destination intrusive container.
The destination container type must support a push(TLink) member function.
Emits an etl::intrusive_stack_empty if the stack is empty and ETL_CHECK_PUSH_POP is defined.
If asserts or exceptions are not enabled then undefined behaviour occurs.
____________________________________________________________________________________________________

void reverse();

Reverses the stack order.
____________________________________________________________________________________________________

void clear();

Clears the stack to a size of zero. No elements are destructed.
intrusive_stack.h