Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ContainingStack Class Template Reference

#include <Stack.h>

List of all members.


Detailed Description

template<class ITEMTYPE>
class toolbox::ContainingStack< ITEMTYPE >

A ContainingStack contains a variable number of items, that are stacked on top of each other and are only accessable one by one from the top end of the stack.

The chaining makes enqueueing and dequeueing fast.

Note:
ContainingStacks contain ContainingStackItems, that are a little more performant, but may not be added twice to the same stack, nor be added to two different stacks. If you require this, use the PointeredStack and PointeredStackItem. To use ContainingStacks, derive at least from the ContainingStackItem, and put your data in there.
See also:
See collections.txt for an overview of the available collection classes.

PointeredStack

PointeredStackItem

Author:
Thomas Jacob

Definition at line 34 of file Stack.h.

Public Member Functions

 ContainingStack ()
 Creates a new stack.

bool Delete ()
 Deletes the top item from the stack.

void DeleteAll ()
 Deletes all items from the stack.

long GetCount () const
 Returns the number of items in the stack.

bool IsEmpty () const
 Returns, if there are no items in the stack.

ITEMTYPE * Peek () const
 Returns the top item of the stack.

ITEMTYPE * Pop ()
 Removes the top item of the stack.

void PopAll ()
 Removes all items from the stack without freeing them or returning them.

void Push (ITEMTYPE *NewItem)
 Puts an item on the top of the stack.

virtual ~ContainingStack ()
 Destroys the stack.


Private Attributes

long Count
 The number of items in the stack.

ITEMTYPE * Top
 The top stack item.


Constructor & Destructor Documentation

ContainingStack  ) 
 

Creates a new stack.

virtual ~ContainingStack  )  [virtual]
 

Destroys the stack.

When deleting the stack, all contained items are also freed.


Member Function Documentation

bool Delete  ) 
 

Deletes the top item from the stack.

The item is removed from the stack and freed.

Returns:
If the deletion was successful.

void DeleteAll  ) 
 

Deletes all items from the stack.

All items are removed from the stack and freed.

long GetCount  )  const [inline]
 

Returns the number of items in the stack.

Returns:
The number of items in the stack.

bool IsEmpty  )  const [inline]
 

Returns, if there are no items in the stack.

ITEMTYPE* Peek  )  const [inline]
 

Returns the top item of the stack.

Returns:
The top item of the stack.

ITEMTYPE* Pop  ) 
 

Removes the top item of the stack.

The item is not freed, but returned.

Returns:
The item.

void PopAll  ) 
 

Removes all items from the stack without freeing them or returning them.

Warning:
No item is freed, so you have to have a pointer to the objects, or the memory is lost.

void Push ITEMTYPE *  NewItem  ) 
 

Puts an item on the top of the stack.

Parameters:
Item The item to be put on top.


Member Data Documentation

long Count [private]
 

The number of items in the stack.

Definition at line 41 of file Stack.h.

ITEMTYPE* Top [private]
 

The top stack item.

Definition at line 53 of file Stack.h.


The documentation for this class was generated from the following file:
Generated on Tue Oct 3 00:23:39 2006 for ToolBox by doxygen 1.3.6