PUMA Library Reference Manual
Puma::PtrStack< T > Class Template Reference

#include <Puma/PtrStack.h>

+ Inheritance diagram for Puma::PtrStack< T >:

Description

template<class T>
class Puma::PtrStack< T >

Layered stack for pointers to objects. Each layer is a separate stack. Layers can be added, dropped, or destroyed.

Public Member Functions

 PtrStack (long size=8192, long incr=8192)
 Construct a new layered stack. More...
 
virtual ~PtrStack ()
 Destructor. More...
 
Stack operations
void Push (const T *item)
 Add a new item on the top of the current layer. More...
 
void Pop ()
 Remove the top item from the current layer. More...
 
T * Top () const
 Get the top item from the current layer. More...
 
long Length () const
 Get the number of items added to the current layer. More...
 
T * Get (long n) const
 Get the n-th item on the current layer. More...
 

Layer operations

void New ()
 Create a new layer. More...
 
void Forget ()
 Remove the top layer and add its items to the underlying layer. More...
 
void Reject ()
 Remove the top layer. More...
 
void Destroy ()
 Remove the top layer and delete its items. More...
 
long Stacks () const
 Get the number of layers. More...
 
void Reset ()
 Remove all layers. More...
 
virtual void Remove ()
 Remove the top item of the current layer. More...
 
virtual void Delete ()
 Remove and delete the top item of the current layer. More...
 

Constructor & Destructor Documentation

◆ PtrStack()

template<class T >
Puma::PtrStack< T >::PtrStack ( long  size = 8192,
long  incr = 8192 
)
inline

Construct a new layered stack.

Parameters
sizeThe size of each layer. Defaults to 8192.
incrThe increment for the size of each layer. Defaults to 8192.

◆ ~PtrStack()

template<class T>
virtual Puma::PtrStack< T >::~PtrStack ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ Delete()

template<class T >
void Puma::PtrStack< T >::Delete ( )
inlineprotectedvirtual

Remove and delete the top item of the current layer.

Reimplemented in Puma::Semantic, Puma::CCBuilder, Puma::Builder, Puma::CCSemantic, and Puma::CSemantic.

◆ Destroy()

template<class T >
void Puma::PtrStack< T >::Destroy ( )
inline

Remove the top layer and delete its items.

◆ Forget()

template<class T >
void Puma::PtrStack< T >::Forget ( )
inline

Remove the top layer and add its items to the underlying layer.

◆ Get()

template<class T >
T * Puma::PtrStack< T >::Get ( long  n) const
inline

Get the n-th item on the current layer.

Parameters
nThe index of the item to get.
Returns
The n-th item, or NULL if the index is invalid.

◆ Length()

template<class T >
long Puma::PtrStack< T >::Length ( ) const
inline

Get the number of items added to the current layer.

Returns
The number of items on the current layer.

◆ New()

template<class T >
void Puma::PtrStack< T >::New ( )
inline

Create a new layer.

◆ Pop()

template<class T >
void Puma::PtrStack< T >::Pop ( )
inline

Remove the top item from the current layer.

◆ Push()

template<class T>
void Puma::PtrStack< T >::Push ( const T *  item)
inline

Add a new item on the top of the current layer.

Parameters
itemThe item to add.

◆ Reject()

template<class T >
void Puma::PtrStack< T >::Reject ( )
inline

Remove the top layer.

◆ Remove()

template<class T >
void Puma::PtrStack< T >::Remove ( )
inlineprotectedvirtual

Remove the top item of the current layer.

◆ Reset()

template<class T >
void Puma::PtrStack< T >::Reset ( )
inline

Remove all layers.

◆ Stacks()

template<class T >
long Puma::PtrStack< T >::Stacks ( ) const
inline

Get the number of layers.

Returns
Number of the layers.

◆ Top()

template<class T >
T * Puma::PtrStack< T >::Top ( ) const
inline

Get the top item from the current layer.

Returns
The top item, or NULL if the current layer is empty.