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

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...
 

Detailed Description

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

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.

Constructor & Destructor Documentation

◆ ArrayStack()

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

Default constructor.

Definition at line 130 of file ArrayStack.h.

◆ ~ArrayStack()

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

Destructor.

Definition at line 140 of file ArrayStack.h.

Member Function Documentation

◆ allocate()

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

Initialize and allocate required memory.

Parameters
capacitymaximum size of stack

Definition at line 151 of file ArrayStack.h.

References UTIL_THROW.

◆ push()

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 187 of file ArrayStack.h.

References UTIL_THROW.

◆ pop()

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 200 of file ArrayStack.h.

References UTIL_THROW.

◆ capacity()

template<typename Data >
int Util::ArrayStack< Data >::capacity

Return capacity of the underlying array.

Returns
Number of elements allocated in array.

Definition at line 173 of file ArrayStack.h.

◆ size()

template<typename Data >
int Util::ArrayStack< Data >::size
inline

◆ peek() [1/2]

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

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

Definition at line 215 of file ArrayStack.h.

◆ peek() [2/2]

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

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

Definition at line 222 of file ArrayStack.h.

◆ isValid()

template<typename Data >
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.

◆ isAllocated()

template<typename Data >
bool Util::ArrayStack< Data >::isAllocated
inline

Return true only if the ArrayStack has been allocated.

Definition at line 265 of file ArrayStack.h.


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