« Back to documentation index
stack< T, SIZE > Class Template Reference
A fixed capacity stack.
More...
#include <stack.h >
Inherits etl::istack< T > .
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 Member Functions
stack ()
Default constructor.
stack (const stack &rhs)
Copy constructor.
~stack ()
Destructor.
stack & operator= (const stack &rhs)
Assignment operator.
reference top ()
Gets a reference to the value at the top of the stack.
const_reference top () const
Gets a const reference to the value at the top of the stack.
void push (parameter_t value)
Adds a value to the stack.
reference push ()
Allows a possibly more efficient 'push' by moving to the next input value and returning a reference to it.
template<typename T1 >
void emplace (const T1 &value1)
Constructs a value in the stack place'.
template<typename T1 , typename T2 >
void emplace (const T1 &value1, const T2 &value2)
Constructs a value in the stack place'.
template<typename T1 , typename T2 , typename T3 >
void emplace (const T1 &value1, const T2 &value2, const T3 &value3)
Constructs a value in the stack place'.
template<typename T1 , typename T2 , typename T3 , typename T4 >
void emplace (const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Constructs a value in the stack place'.
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)
Removes the oldest item from the top of the stack and pushes it to the destination container.
void reverse ()
Reverses the stack.
bool empty () const
Checks to see if the stack is empty.
bool full () const
Checks to see if the stack is full.
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
Returns the remaining capacity.
Protected Member Functions
void clone (const istack &other)
Make this a clone of the supplied stack.
void add_in ()
Increments the indexes value to record a stack addition.
void del_out ()
Decrements the indexes value to record a queue deletion.
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.
etl::debug_count construct_count
For internal debugging purposes.
Detailed Description
template<typename T, const size_t SIZE>
class etl::stack< T, SIZE >
A fixed capacity stack.
This stack does not suppo7rt concurrent access by different threads.
Template Parameters:
T The type this stack should support.
MAX_SIZE The maximum capacity of the stack.
Definition at line 438 of file stack.h .
Member Typedef Documentation
A const pointer to the type used in the stack.
Definition at line 212 of file stack.h .
A const reference to the type used in the stack.
Definition at line 210 of file stack.h .
A pointer to the type used in the stack.
Definition at line 211 of file stack.h .
A reference to the type used in the stack.
Definition at line 209 of file stack.h .
The type used for determining the size of the stack.
Reimplemented from stack_base .
Definition at line 213 of file stack.h .
The type stored in the stack.
Definition at line 208 of file stack.h .
Constructor & Destructor Documentation
Default constructor.
Definition at line 447 of file stack.h .
Copy constructor.
Definition at line 455 of file stack.h .
Destructor.
Definition at line 464 of file stack.h .
Member Function Documentation
void add_in
(
)
[protected, inherited]
Increments the indexes value to record a stack addition.
Definition at line 170 of file stack.h .
size_t available
(
)
const [inherited]
Returns the remaining capacity.
Returns: The remaining capacity.
Definition at line 150 of file stack.h .
void clear
(
)
[inherited]
Clears the stack to the empty state.
Definition at line 334 of file stack.h .
void clone
(
const istack < T > &
other )
[protected, inherited]
Make this a clone of the supplied stack.
Definition at line 403 of file stack.h .
void del_out
(
)
[protected, inherited]
Decrements the indexes value to record a queue deletion.
Definition at line 179 of file stack.h .
void emplace
(
const T1 &
value1 ,
const T2 &
value2 ,
const T3 &
value3 ,
const T4 &
value4
)
[inherited]
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:
value The value to push to the stack.
Definition at line 296 of file stack.h .
void emplace
(
const T1 &
value1 ,
const T2 &
value2 ,
const T3 &
value3
)
[inherited]
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:
value The value to push to the stack.
Definition at line 281 of file stack.h .
void emplace
(
const T1 &
value1 )
[inherited]
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:
value The value to push to the stack.
Definition at line 251 of file stack.h .
void emplace
(
const T1 &
value1 ,
const T2 &
value2
)
[inherited]
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:
value The value to push to the stack.
Definition at line 266 of file stack.h .
bool empty
(
)
const [inherited]
Checks to see if the stack is empty.
Returns: true if the stack is empty, otherwise false
Definition at line 116 of file stack.h .
bool full
(
)
const [inherited]
Checks to see if the stack is full.
Returns: true if the stack is full, otherwise false
Definition at line 125 of file stack.h .
Returns the maximum number of items that can be stacked.
Definition at line 141 of file stack.h .
Assignment operator.
Definition at line 472 of file stack.h .
Removes the oldest item from the top of the stack.
Definition at line 346 of file stack.h .
void pop_into
(
TContainer &
destination )
[inherited]
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.
Definition at line 370 of file stack.h .
void pop_into
(
reference
destination )
[inherited]
Removes the oldest item from the top of the stack and puts it in the destination.
Definition at line 358 of file stack.h .
void push
(
parameter_t
value )
[inherited]
Adds a value to the stack.
If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.
Parameters:
value The value to push to the stack.
Definition at line 236 of file stack.h .
Allows a possibly more efficient 'push' by moving to the next input value and returning a reference to it.
This may eliminate a copy by allowing direct construction in-place.
If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.
Returns: A reference to the position to 'push' to.
Definition at line 312 of file stack.h .
void reverse
(
)
[inherited]
Reverses the stack.
Definition at line 379 of file stack.h .
Returns the current number of items top the stack.
Definition at line 133 of file stack.h .
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.
Definition at line 326 of file stack.h .
Gets a reference to the value at the top of the stack.
Returns: A reference to the value at the top of the stack.
Definition at line 226 of file stack.h .
Field Documentation
The maximum number of items in the stack.
Definition at line 188 of file stack.h .
For internal debugging purposes.
Definition at line 189 of file stack.h .
The number of items in the stack.
Definition at line 187 of file stack.h .
The index of the top of the stack.
Definition at line 186 of file stack.h .