PUMA Library Reference Manual
Loading...
Searching...
No Matches
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.
 
virtual ~PtrStack ()
 Destructor.
 
Stack operations
void Push (const T *item)
 Add a new item on the top of the current layer.
 
void Pop ()
 Remove the top item from the current layer.
 
T * Top () const
 Get the top item from the current layer.
 
long Length () const
 Get the number of items added to the current layer.
 
T * Get (long n) const
 Get the n-th item on the current layer.
 

Layer operations

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

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::Builder, Puma::CCBuilder, Puma::CCSemantic, Puma::CSemantic, and Puma::Semantic.

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