# PStack< T > Class Template Reference

This template class maps the PAbstractList to a specific object type, and adds functionality that allows the list to be used as a last in first out stack. More...

`#include <lists.h>`

Inheritance diagram for PStack< T >:

List of all members.

## Public Member Functions

Construction
| PStack ()
| Create a new, empty, stack.
Overrides from class PObject
virtual PObject * | Clone () const
| Make a complete duplicate of the stack.
New functions for class
virtual void | Push (T *obj)
| Add an object to the stack.
virtual T * | Pop ()
| Remove the last object pushed onto the stack.
virtual T & | Top ()
| Get the element that is currently on top of the stack without removing it.

## Protected Member Functions

| PStack (int dummy, const PStack *c)

## Detailed Description

### template<class T>
class PStack< T >

This template class maps the PAbstractList to a specific object type, and adds functionality that allows the list to be used as a last in first out stack.

The functions in this class primarily do all the appropriate casting of types.

By default, objects placed into the set will not be deleted when removed or when all references to the set are destroyed. This is different from the default on most collection classes.

Note that if templates are not used the `PDECLARE_STACK` macro will simulate the template instantiation.

## Constructor & Destructor Documentation

template<class T>

PStack< T >::PStack | ( |  | ) | `[inline]`

Create a new, empty, stack.

Note that by default, objects placed into the stack will not be deleted when removed or when all references to the stack are destroyed. This is different from the default on most collection classes.

template<class T>

PStack< T >::PStack | ( | int | dummy,
|  | const PStack< T > * | c |
| ) |  |  | `[inline, protected]`

## Member Function Documentation

template<class T>

virtual PObject* PStack< T >::Clone | ( |  | ) | const`[inline, virtual]`

Make a complete duplicate of the stack.

Note that all objects in the array are also cloned, so this will make a complete copy of the stack.

Reimplemented from PObject.

template<class T>

virtual T* PStack< T >::Pop | ( |  | ) | `[inline, virtual]`

Remove the last object pushed onto the stack.

Returns:
  object on top of the stack.

template<class T>

virtual void PStack< T >::Push | ( | T * | obj | ) | `[inline, virtual]`

Add an object to the stack.

This object will be on "top" of the stack and will be the object returned by the `Pop()` function.

Parameters:

  obj | Object to add to the stack.

template<class T>

virtual T& PStack< T >::Top | ( |  | ) | `[inline, virtual]`

Get the element that is currently on top of the stack without removing it.

Returns:
  reference to object on top of the stack.

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

- lists.h