Embedded Template Library 1.0
stack

Classes

class  etl::array_view_bounds
 
class  etl::array_view_uninitialised
 
class  etl::array_wrapper_bounds
 
class  etl::intrusive_stack_base< TLink >
 
class  etl::intrusive_stack< TValue, TLink >
 
class  etl::stack_exception
 
class  etl::stack_full
 
class  etl::stack_empty
 
class  etl::stack_base
 
class  etl::istack< T >
 This is the base for all stacks that contain a particular type. More...
 
class  etl::stack< T, SIZE >
 
class  etl::string_view_bounds
 
class  etl::string_view_uninitialised
 

Detailed Description

A Last-in / first-out stack with the capacity defined at compile time, written in the STL style.


Class Documentation

◆ etl::array_view_bounds

class etl::array_view_bounds

The exception thrown when the index is out of bounds.

Public Member Functions

 array_view_bounds (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::array_view_exception
 array_view_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::array_view_uninitialised

class etl::array_view_uninitialised

The exception thrown when the view is uninitialised.

Public Member Functions

 array_view_uninitialised (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::array_view_exception
 array_view_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::array_wrapper_bounds

class etl::array_wrapper_bounds

The exception thrown when the index is out of bounds.

Public Member Functions

 array_wrapper_bounds (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::array_wrapper_exception
 array_wrapper_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::intrusive_stack_base

class etl::intrusive_stack_base
template<typename TLink>
class etl::intrusive_stack_base< TLink >

Base for intrusive stack. Stores elements derived any type that supports an 'etl_next' pointer member.

Template Parameters
TLinkThe link type that the value is derived from.

Public Types

typedef TLink link_type
 

Public Member Functions

void push (link_type &value)
 
void pop ()
 
template<typename TContainer >
void pop_into (TContainer &destination)
 
void reverse ()
 Reverses the stack order.
 
void clear ()
 Clears the stack to the empty state.
 
bool empty () const
 Checks if the stack is in the empty state.
 
size_t size () const
 Returns the number of elements.
 

Protected Member Functions

 intrusive_stack_base ()
 Constructor.
 
 ~intrusive_stack_base ()
 Destructor.
 

Protected Attributes

link_type * p_top
 The current top of the stack.
 
link_type terminator
 Terminator link of the queue.
 
size_t current_size
 Counts the number of elements in the list.
 

Member Function Documentation

◆ pop()

template<typename TLink >
void etl::intrusive_stack_base< TLink >::pop ( )
inline

Removes the oldest item from the top of the stack. Undefined behaviour if the stack is already empty.

◆ pop_into()

template<typename TLink >
template<typename TContainer >
void etl::intrusive_stack_base< TLink >::pop_into ( TContainer &  destination)
inline

Removes the oldest item from the queue and pushes it to the destination. Undefined behaviour if the queue is already empty. NOTE: The destination must be an intrusive container that supports a push(TLink) member function.

◆ push()

template<typename TLink >
void etl::intrusive_stack_base< TLink >::push ( link_type &  value)
inline

Adds a value to the stack.

Parameters
valueThe value to push to the stack.

◆ etl::intrusive_stack

class etl::intrusive_stack
template<typename TValue, typename TLink>
class etl::intrusive_stack< TValue, TLink >

An intrusive stack. Stores elements derived from any type that supports an 'etl_next' pointer member.

Warning
This stack cannot be used for concurrent access from multiple threads.
Template Parameters
TValueThe type of value that the stack holds.
TLinkThe link type that the value is derived from.

Public Types

typedef etl::intrusive_stack_base< TLink >::link_type link_type
 
typedef TValue value_type
 
typedef value_type * pointer
 
typedef const value_type * const_pointer
 
typedef value_type & reference
 
typedef const value_type & const_reference
 
typedef size_t size_type
 
- Public Types inherited from etl::intrusive_stack_base< TLink >
typedef TLink link_type
 

Public Member Functions

 intrusive_stack ()
 Constructor.
 
reference top ()
 
const_reference top () const
 
- Public Member Functions inherited from etl::intrusive_stack_base< TLink >
void push (link_type &value)
 
void pop ()
 
template<typename TContainer >
void pop_into (TContainer &destination)
 
void reverse ()
 Reverses the stack order.
 
void clear ()
 Clears the stack to the empty state.
 
bool empty () const
 Checks if the stack is in the empty state.
 
size_t size () const
 Returns the number of elements.
 

Additional Inherited Members

- Protected Member Functions inherited from etl::intrusive_stack_base< TLink >
 intrusive_stack_base ()
 Constructor.
 
 ~intrusive_stack_base ()
 Destructor.
 
- Protected Attributes inherited from etl::intrusive_stack_base< TLink >
link_type * p_top
 The current top of the stack.
 
link_type terminator
 Terminator link of the queue.
 
size_t current_size
 Counts the number of elements in the list.
 

Member Function Documentation

◆ top() [1/2]

template<typename TValue , typename TLink >
reference etl::intrusive_stack< TValue, TLink >::top ( )
inline

Gets a reference to the value at the top of the stack. Undefined behaviour if the stack is empty.

Returns
A reference to the value at the top of the stack.

◆ top() [2/2]

template<typename TValue , typename TLink >
const_reference etl::intrusive_stack< TValue, TLink >::top ( ) const
inline

Gets a const reference to the value at the top of the stack.

Returns
A const reference to the value at the top of the stack.

◆ etl::stack_exception

class etl::stack_exception

The base class for stack exceptions.

Public Member Functions

 stack_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::stack_full

class etl::stack_full

The exception thrown when the stack is full.

Public Member Functions

 stack_full (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::stack_exception
 stack_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::stack_empty

class etl::stack_empty

The exception thrown when the stack is empty.

Public Member Functions

 stack_empty (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::stack_exception
 stack_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::stack_base

class etl::stack_base

A fixed capacity stack written in the STL style.

Warning
This stack cannot be used for concurrent access from multiple threads.

Public Types

typedef size_t size_type
 The type used for determining the size of stack.
 

Public Member Functions

bool empty () const
 
bool full () const
 
size_type size () const
 Returns the current number of items top the stack.
 
size_type max_size () const
 Returns the maximum number of items that can be stacked.
 
size_t available () const
 

Protected Member Functions

 stack_base (size_type max_size_)
 The constructor that is called from derived classes.
 
 ~stack_base ()
 Destructor.
 
void add_in ()
 Increments the indexes value to record a stack addition.
 
void del_out ()
 Decrements the indexes value to record a queue deletion.
 
void index_clear ()
 Clears all of the indexes.
 

Protected Attributes

size_type top_index
 The index of the top of the stack.
 
size_type current_size
 The number of items in the stack.
 
const size_type CAPACITY
 The maximum number of items in the stack.
 

Member Function Documentation

◆ available()

size_t etl::stack_base::available ( ) const
inline

Returns the remaining capacity.

Returns
The remaining capacity.

◆ empty()

bool etl::stack_base::empty ( ) const
inline

Checks to see if the stack is empty.

Returns
true if the stack is empty, otherwise false

◆ full()

bool etl::stack_base::full ( ) const
inline

Checks to see if the stack is full.

Returns
true if the stack is full, otherwise false

◆ etl::istack

class etl::istack
template<typename T>
class etl::istack< T >

This is the base for all stacks that contain a particular type.

Normally a reference to this type will be taken from a derived stack.

etl::istack<int>& iStack = myStack;
This is the base for all stacks that contain a particular type.
Definition: stack.h:221
Definition: stack.h:529
Warning
This stack cannot be used for concurrent access from multiple threads.
Template Parameters
TThe type of value that the stack holds.

Public Types

typedef T value_type
 The type stored in the stack.
 
typedef T & reference
 A reference to the type used in the stack.
 
typedef const T & const_reference
 A const reference to the type used in the stack.
 
typedef T * pointer
 A pointer to the type used in the stack.
 
typedef const T * const_pointer
 A const pointer to the type used in the stack.
 
typedef stack_base::size_type size_type
 The type used for determining the size of the stack.
 
- Public Types inherited from etl::stack_base
typedef size_t size_type
 The type used for determining the size of stack.
 

Public Member Functions

reference top ()
 
void push (const_reference value)
 
template<typename T1 >
void emplace (const T1 &value1)
 
template<typename T1 , typename T2 >
void emplace (const T1 &value1, const T2 &value2)
 
template<typename T1 , typename T2 , typename T3 >
void emplace (const T1 &value1, const T2 &value2, const T3 &value3)
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
void emplace (const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
 
const_reference top () const
 
void clear ()
 Clears the stack to the empty state.
 
void pop ()
 Removes the oldest item from the top of the stack.
 
void pop_into (reference destination)
 Removes the oldest item from the top of the stack and puts it in the destination.
 
template<typename TContainer >
void pop_into (TContainer &destination)
 
void reverse ()
 Reverses the stack.
 
istackoperator= (const istack &rhs)
 Assignment operator.
 
- Public Member Functions inherited from etl::stack_base
bool empty () const
 
bool full () const
 
size_type size () const
 Returns the current number of items top the stack.
 
size_type max_size () const
 Returns the maximum number of items that can be stacked.
 
size_t available () const
 

Protected Member Functions

void clone (const istack &other)
 Make this a clone of the supplied stack.
 
 istack (T *p_buffer_, size_type max_size_)
 The constructor that is called from derived classes.
 
 ~istack ()
 Destructor.
 
- Protected Member Functions inherited from etl::stack_base
 stack_base (size_type max_size_)
 The constructor that is called from derived classes.
 
 ~stack_base ()
 Destructor.
 
void add_in ()
 Increments the indexes value to record a stack addition.
 
void del_out ()
 Decrements the indexes value to record a queue deletion.
 
void index_clear ()
 Clears all of the indexes.
 

Additional Inherited Members

- Protected Attributes inherited from etl::stack_base
size_type top_index
 The index of the top of the stack.
 
size_type current_size
 The number of items in the stack.
 
const size_type CAPACITY
 The maximum number of items in the stack.
 

Member Function Documentation

◆ emplace() [1/4]

template<typename T >
template<typename T1 >
void etl::istack< T >::emplace ( const T1 &  value1)
inline

Constructs a value in the stack place'. If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.

Parameters
valueThe value to push to the stack.

◆ emplace() [2/4]

template<typename T >
template<typename T1 , typename T2 >
void etl::istack< T >::emplace ( const T1 &  value1,
const T2 &  value2 
)
inline

Constructs a value in the stack place'. If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.

Parameters
valueThe value to push to the stack.

◆ emplace() [3/4]

template<typename T >
template<typename T1 , typename T2 , typename T3 >
void etl::istack< T >::emplace ( const T1 &  value1,
const T2 &  value2,
const T3 &  value3 
)
inline

Constructs a value in the stack place'. If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.

Parameters
valueThe value to push to the stack.

◆ emplace() [4/4]

template<typename T >
template<typename T1 , typename T2 , typename T3 , typename T4 >
void etl::istack< T >::emplace ( const T1 &  value1,
const T2 &  value2,
const T3 &  value3,
const T4 &  value4 
)
inline

Constructs a value in the stack place'. If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.

Parameters
valueThe value to push to the stack.

◆ pop_into()

template<typename T >
template<typename TContainer >
void etl::istack< T >::pop_into ( TContainer &  destination)
inline

Removes the oldest item from the top of the stack and pushes it to the destination container. NOTE: The destination must support a push(T) member function.

◆ push()

template<typename T >
void etl::istack< T >::push ( const_reference  value)
inline

Adds a value to the stack. If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.

Parameters
valueThe value to push to the stack.

◆ top() [1/2]

template<typename T >
reference etl::istack< T >::top ( )
inline

Gets a reference to the value at the top of the stack.

Returns
A reference to the value at the top of the stack.

◆ top() [2/2]

template<typename T >
const_reference etl::istack< T >::top ( ) const
inline

Gets a const reference to the value at the top of the stack.

Returns
A const reference to the value at the top of the stack.

◆ etl::stack

class etl::stack
template<typename T, const size_t SIZE>
class etl::stack< T, SIZE >

A fixed capacity stack. This stack does not support concurrent access by different threads.

Template Parameters
TThe type this stack should support.
MAX_SIZEThe maximum capacity of the stack.

Public Types

typedef etl::aligned_storage< sizeof(T), etl::alignment_of< T >::value >::type container_type
 
- Public Types inherited from etl::istack< T >
typedef T value_type
 The type stored in the stack.
 
typedef T & reference
 A reference to the type used in the stack.
 
typedef const T & const_reference
 A const reference to the type used in the stack.
 
typedef T * pointer
 A pointer to the type used in the stack.
 
typedef const T * const_pointer
 A const pointer to the type used in the stack.
 
typedef stack_base::size_type size_type
 The type used for determining the size of the stack.
 
- Public Types inherited from etl::stack_base
typedef size_t size_type
 The type used for determining the size of stack.
 

Public Member Functions

 stack ()
 Default constructor.
 
 stack (const stack &rhs)
 Copy constructor.
 
 ~stack ()
 Destructor.
 
stackoperator= (const stack &rhs)
 Assignment operator.
 
- Public Member Functions inherited from etl::istack< T >
reference top ()
 
void push (const_reference value)
 
template<typename T1 >
void emplace (const T1 &value1)
 
template<typename T1 , typename T2 >
void emplace (const T1 &value1, const T2 &value2)
 
template<typename T1 , typename T2 , typename T3 >
void emplace (const T1 &value1, const T2 &value2, const T3 &value3)
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
void emplace (const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
 
const_reference top () const
 
void clear ()
 Clears the stack to the empty state.
 
void pop ()
 Removes the oldest item from the top of the stack.
 
void pop_into (reference destination)
 Removes the oldest item from the top of the stack and puts it in the destination.
 
template<typename TContainer >
void pop_into (TContainer &destination)
 
void reverse ()
 Reverses the stack.
 
istackoperator= (const istack &rhs)
 Assignment operator.
 
- Public Member Functions inherited from etl::stack_base
bool empty () const
 
bool full () const
 
size_type size () const
 Returns the current number of items top the stack.
 
size_type max_size () const
 Returns the maximum number of items that can be stacked.
 
size_t available () const
 

Static Public Attributes

static ETL_CONSTANT size_t MAX_SIZE = SIZE
 

Additional Inherited Members

- Protected Member Functions inherited from etl::istack< T >
void clone (const istack &other)
 Make this a clone of the supplied stack.
 
 istack (T *p_buffer_, size_type max_size_)
 The constructor that is called from derived classes.
 
 ~istack ()
 Destructor.
 
- Protected Member Functions inherited from etl::stack_base
 stack_base (size_type max_size_)
 The constructor that is called from derived classes.
 
 ~stack_base ()
 Destructor.
 
void add_in ()
 Increments the indexes value to record a stack addition.
 
void del_out ()
 Decrements the indexes value to record a queue deletion.
 
void index_clear ()
 Clears all of the indexes.
 
- Protected Attributes inherited from etl::stack_base
size_type top_index
 The index of the top of the stack.
 
size_type current_size
 The number of items in the stack.
 
const size_type CAPACITY
 The maximum number of items in the stack.
 

◆ etl::string_view_bounds

class etl::string_view_bounds

The exception thrown when the index is out of bounds.

Public Member Functions

 string_view_bounds (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::string_view_exception
 string_view_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type
 

◆ etl::string_view_uninitialised

class etl::string_view_uninitialised

The exception thrown when the view is uninitialised.

Public Member Functions

 string_view_uninitialised (string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::string_view_exception
 string_view_exception (string_type reason_, string_type file_name_, numeric_type line_number_)
 
- Public Member Functions inherited from etl::exception
ETL_CONSTEXPR exception (string_type reason_, string_type, numeric_type line_)
 Constructor.
 
ETL_CONSTEXPR string_type what () const
 
ETL_CONSTEXPR string_type file_name () const
 
ETL_CONSTEXPR numeric_type line_number () const
 

Additional Inherited Members

- Public Types inherited from etl::exception
typedef const char * string_type
 
typedef int numeric_type