PUMA Library Reference Manual
Puma::Stack< Item > Class Template Reference

#include <Puma/Stack.h>

+ Inheritance diagram for Puma::Stack< Item >:

Description

template<class Item>
class Puma::Stack< Item >

Stack implementation based on a variable length array.

Template Parameters
ItemThe stack item type.

Public Member Functions

 Stack (long is=8192, long incr=8192)
 Construct a new stack. More...
 
void push (Item item)
 Add a new item on top of the stack. More...
 
Item & top () const
 Get the top item from the stack. More...
 
void pop ()
 Remove the top item from the stack. More...
 
long length () const
 Get the number of items on the stack. More...
 
void reset ()
 Reset the stack. More...
 

Constructor & Destructor Documentation

◆ Stack()

template<class Item>
Puma::Stack< Item >::Stack ( long  is = 8192,
long  incr = 8192 
)
inline

Construct a new stack.

Parameters
isThe default size of the stack.
incrThe default increment value for the stack size.

Member Function Documentation

◆ length()

template<class Item>
long Puma::Stack< Item >::length ( ) const
inline

Get the number of items on the stack.

Returns
The number of items.

◆ pop()

template<class Item>
void Puma::Stack< Item >::pop ( )
inline

Remove the top item from the stack.

◆ push()

template<class Item>
void Puma::Stack< Item >::push ( Item  item)
inline

Add a new item on top of the stack.

Parameters
itemThe item to add.

◆ reset()

template<class Item>
void Puma::Stack< Item >::reset ( )
inline

Reset the stack.

◆ top()

template<class Item>
Item& Puma::Stack< Item >::top ( ) const
inline

Get the top item from the stack.

Returns
A reference to the top stack item.