Simpatico
v1.10
|
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... | |
Util::ArrayStack< Data >::ArrayStack | ( | ) |
Default constructor.
Definition at line 126 of file ArrayStack.h.
|
virtual |
Destructor.
Definition at line 136 of file ArrayStack.h.
void Util::ArrayStack< Data >::allocate | ( | int | capacity | ) |
Initialize and allocate required memory.
capacity | maximum size of stack. |
Definition at line 147 of file ArrayStack.h.
References Util::ArrayStack< Data >::capacity(), and UTIL_THROW.
void Util::ArrayStack< Data >::push | ( | Data & | data | ) |
Push an element onto the Stack.
data | element to be added to stack. |
Definition at line 183 of file ArrayStack.h.
References UTIL_THROW.
Data & Util::ArrayStack< Data >::pop | ( | ) |
Pop an element off the stack.
Definition at line 196 of file ArrayStack.h.
References UTIL_THROW.
int Util::ArrayStack< Data >::capacity | ( | ) | const |
Return capacity of the underlying array.
Definition at line 169 of file ArrayStack.h.
Referenced by Util::ArrayStack< Data >::allocate().
|
inline |
Get the number of elements in the stack.
Definition at line 176 of file ArrayStack.h.
|
inline |
Return a reference to the top element (don't pop).
Definition at line 211 of file ArrayStack.h.
|
inline |
Return a const ref to the top element (don't pop).
Definition at line 218 of file ArrayStack.h.
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.
|
inline |
Return true only if the ArrayStack has been allocated.
Definition at line 261 of file ArrayStack.h.