PSCF v1.1
|
An automatically growable Stack. More...
#include <GStack.h>
Public Member Functions | |
GStack () | |
Constructor. More... | |
GStack (GStack< Data > const &other) | |
Copy constructor, copy pointers. More... | |
~GStack () | |
Destructor. More... | |
GStack< Data > & | operator= (GStack< Data > const &other) |
Assignment, element by element. More... | |
void | reserve (int capacity) |
Reserve memory for specified number of elements. More... | |
void | deallocate () |
Deallocate (delete) underlying array of pointers. More... | |
void | clear () |
Reset to empty state. More... | |
void | push (Data &data) |
Push an element onto the stack. More... | |
Data & | pop () |
Pop an element off the stack. More... | |
Data & | peek () |
Return a reference to the top element (don't pop). More... | |
Data const & | peek () const |
Return a const ref to the top element (don't pop). More... | |
int | capacity () const |
Return allocated size. More... | |
int | size () const |
Return logical size. More... | |
bool | isAllocated () const |
Is this GStack allocated? More... | |
bool | isValid () const |
Is this GStack in a valid internal state? More... | |
An automatically growable Stack.
A GStack is stack that is implemented as a growable pointer array. Like any pointer array it holds pointers to objects, rather than objects, and associated objects are not destroyed when the container is deallocated or destroyed.
|
inline |
Util::GStack< Data >::GStack | ( | GStack< Data > const & | other | ) |
Util::GStack< Data >::~GStack |
Destructor.
Deletes array of pointers, if allocated previously. Does not delete the associated Data objects.
Definition at line 206 of file GStack.h.
References Util::Memory::deallocate().
GStack< Data > & Util::GStack< Data >::operator= | ( | GStack< Data > const & | other | ) |
void Util::GStack< Data >::reserve | ( | int | capacity | ) |
Reserve memory for specified number of elements.
Resizes and copies array if requested capacity is less than the current capacity. Does nothing if requested capacity is greater than current capacity.
capacity | number of elements for which to reserve space. |
Definition at line 235 of file GStack.h.
References UTIL_THROW.
void Util::GStack< Data >::deallocate |
|
inline |
void Util::GStack< Data >::push | ( | Data & | data | ) |
Data & Util::GStack< Data >::pop |
Pop an element off the stack.
Returns the top element by reference and removes it, decrementing the size by one.
Definition at line 338 of file GStack.h.
References UTIL_THROW.
|
inline |
|
inline |
|
inline |
|
inline |
Return logical size.
Definition at line 374 of file GStack.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 |
bool Util::GStack< Data >::isValid |
Is this GStack in a valid internal state?
Definition at line 388 of file GStack.h.
References UTIL_THROW.