Simpatico  v1.10
List of all members | Public Member Functions
Util::ArrayStack< Data > Class Template Reference

Detailed Description

template<typename Data>
class Util::ArrayStack< Data >

A stack of fixed capacity.

Pointers to elements are stored in an allocatable, non-resizable array.

Definition at line 25 of file ArrayStack.h.

#include <ArrayStack.h>

Public Member Functions

 ArrayStack ()
 Default constructor. More...
 
virtual ~ArrayStack ()
 Destructor. More...
 
void allocate (int capacity)
 Initialize and allocate required memory. More...
 
Mutators
void push (Data &data)
 Push an element onto the Stack. More...
 
Data & pop ()
 Pop an element off the stack. More...
 
Accessors
int capacity () const
 Return capacity of the underlying array. More...
 
int size () const
 Get the number of elements in the stack. More...
 
Data & peek ()
 Return a reference to the top element (don't pop). More...
 
const Data & peek () const
 Return a const ref to the top element (don't pop). More...
 
bool isValid () const
 Return true if the ArrayStack is valid, or throw an exception. More...
 
bool isAllocated () const
 Return true only if the ArrayStack has been allocated. More...
 

Constructor & Destructor Documentation

template<typename Data >
Util::ArrayStack< Data >::ArrayStack ( )

Default constructor.

Definition at line 126 of file ArrayStack.h.

template<typename Data >
Util::ArrayStack< Data >::~ArrayStack ( )
virtual

Destructor.

Definition at line 136 of file ArrayStack.h.

Member Function Documentation

template<typename Data >
void Util::ArrayStack< Data >::allocate ( int  capacity)

Initialize and allocate required memory.

Parameters
capacitymaximum size of stack.

Definition at line 147 of file ArrayStack.h.

References Util::ArrayStack< Data >::capacity(), and UTIL_THROW.

template<typename Data>
void Util::ArrayStack< Data >::push ( Data &  data)

Push an element onto the Stack.

Parameters
dataelement to be added to stack.

Definition at line 183 of file ArrayStack.h.

References UTIL_THROW.

template<typename Data >
Data & Util::ArrayStack< Data >::pop ( )

Pop an element off the stack.

Returns
the top element (which is popped off stack).

Definition at line 196 of file ArrayStack.h.

References UTIL_THROW.

template<typename Data >
int Util::ArrayStack< Data >::capacity ( ) const

Return capacity of the underlying array.

Returns
Number of elements allocated in array.

Definition at line 169 of file ArrayStack.h.

Referenced by Util::ArrayStack< Data >::allocate().

template<typename Data >
int Util::ArrayStack< Data >::size ( ) const
inline

Get the number of elements in the stack.

Definition at line 176 of file ArrayStack.h.

template<typename Data >
Data & Util::ArrayStack< Data >::peek ( )
inline

Return a reference to the top element (don't pop).

Definition at line 211 of file ArrayStack.h.

template<typename Data >
const Data & Util::ArrayStack< Data >::peek ( ) const
inline

Return a const ref to the top element (don't pop).

Definition at line 218 of file ArrayStack.h.

template<typename Data >
bool Util::ArrayStack< Data >::isValid ( ) const

Return true if the ArrayStack is valid, or throw an exception.

Definition at line 225 of file ArrayStack.h.

References UTIL_THROW.

template<typename Data >
bool Util::ArrayStack< Data >::isAllocated ( ) const
inline

Return true only if the ArrayStack has been allocated.

Definition at line 261 of file ArrayStack.h.


The documentation for this class was generated from the following file: