PSCF v1.1
|
A stack of fixed capacity, which stores pointers to elements. More...
#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... | |
A stack of fixed capacity, which stores pointers to elements.
Pointers to elements are stored in an allocatable, non-resizable array.
One natural usage is as a stack of pointers to elements of an associated array of Data objects, for which the maximum number of distinct elements is equal to the capacity of the associated array.
Definition at line 29 of file ArrayStack.h.
Util::ArrayStack< Data >::ArrayStack |
Default constructor.
Definition at line 130 of file ArrayStack.h.
|
virtual |
Destructor.
Definition at line 140 of file ArrayStack.h.
void Util::ArrayStack< Data >::allocate | ( | int | capacity | ) |
Initialize and allocate required memory.
capacity | maximum size of stack |
Definition at line 151 of file ArrayStack.h.
References 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 187 of file ArrayStack.h.
References UTIL_THROW.
Data & Util::ArrayStack< Data >::pop |
Pop an element off the stack.
Definition at line 200 of file ArrayStack.h.
References UTIL_THROW.
int Util::ArrayStack< Data >::capacity |
Return capacity of the underlying array.
Definition at line 173 of file ArrayStack.h.
|
inline |
Get the number of elements in the stack.
Definition at line 180 of file ArrayStack.h.
Referenced by pscfpp.file.File::__eq__(), pscfpp.text.Record::__init__(), pscfpp.file.File::__init__(), pscfpp.file.File::__repr__(), and pscfpp.text.Record::__str__().
|
inline |
Return a reference to the top element (don't pop).
Definition at line 215 of file ArrayStack.h.
|
inline |
Return a const ref to the top element (don't pop).
Definition at line 222 of file ArrayStack.h.
bool Util::ArrayStack< Data >::isValid |
Return true if the ArrayStack is valid, or throw an exception.
Definition at line 229 of file ArrayStack.h.
References UTIL_THROW.
|
inline |
Return true only if the ArrayStack has been allocated.
Definition at line 265 of file ArrayStack.h.