Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

istack< T > Class Template Reference

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

#include <stack.h>

Inherits etl::stack_base.

Inherited by stack< T, SIZE >.

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

reference top ()
 Gets a reference to the value at the top of the stack.
void push (parameter_t value)
 Adds a value to the stack.
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'.
reference push ()
 Allows a possibly more efficient 'push' by moving to the next input value and returning a reference to it.
const_reference top () const
 Gets a const reference to the value at the top of the stack.
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.
istackoperator= (const istack &rhs)
 Assignment operator.
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.
 istack (T *p_buffer_, size_type max_size_)
 The constructor that is called from derived classes.
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>
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::stack<int, 10> myStack;
      etl::istack<int>& iStack = myStack;
Warning:
This stack cannot be used for concurrent access from multiple threads.
Template Parameters:
TThe type of value that the stack holds.

Definition at line 204 of file stack.h.


Member Typedef Documentation

typedef const T* const_pointer

A const pointer to the type used in the stack.

Definition at line 212 of file stack.h.

typedef const T& const_reference

A const reference to the type used in the stack.

Definition at line 210 of file stack.h.

typedef T* pointer

A pointer to the type used in the stack.

Definition at line 211 of file stack.h.

typedef T& reference

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.

typedef T value_type

The type stored in the stack.

Definition at line 208 of file stack.h.


Constructor & Destructor Documentation

istack ( T *  p_buffer_,
size_type  max_size_ 
) [protected]

The constructor that is called from derived classes.

Definition at line 416 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 (  )

Clears the stack to the empty state.

Definition at line 334 of file stack.h.

void clone ( const istack< T > &  other ) [protected]

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 
)

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.

Definition at line 266 of file stack.h.

void emplace ( const T1 &  value1,
const T2 &  value2,
const T3 &  value3 
)

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.

Definition at line 281 of file stack.h.

void emplace ( const T1 &  value1 )

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.

Definition at line 251 of file stack.h.

void emplace ( const T1 &  value1,
const T2 &  value2,
const T3 &  value3,
const T4 &  value4 
)

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.

Definition at line 296 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.

size_type max_size (  ) const [inherited]

Returns the maximum number of items that can be stacked.

Definition at line 141 of file stack.h.

istack& operator= ( const istack< T > &  rhs )

Assignment operator.

Definition at line 387 of file stack.h.

void pop (  )

Removes the oldest item from the top of the stack.

Definition at line 346 of file stack.h.

void pop_into ( reference  destination )

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 pop_into ( TContainer &  destination )

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.

reference push (  )

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 push ( parameter_t  value )

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.

Definition at line 236 of file stack.h.

void reverse (  )

Reverses the stack.

Definition at line 379 of file stack.h.

size_type size (  ) const [inherited]

Returns the current number of items top the stack.

Definition at line 133 of file stack.h.

reference top (  )

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.

const_reference top (  ) const

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.


Field Documentation

const size_type CAPACITY [protected, inherited]

The maximum number of items in the stack.

Definition at line 188 of file stack.h.

etl::debug_count construct_count [protected, inherited]

For internal debugging purposes.

Definition at line 189 of file stack.h.

size_type current_size [protected, inherited]

The number of items in the stack.

Definition at line 187 of file stack.h.

size_type top_index [protected, inherited]

The index of the top of the stack.

Definition at line 186 of file stack.h.