DStack< dataType > Class Template Reference

A dynamic stack implementation. More...

#include <dstack.h>

List of all members.

Public Member Functions

 DStack (size_t _size=-1)
 The constructor.
 ~DStack ()
 The destructor.
void grow ()
 Increases the array size by the number in m_stepSize.
void push (dataType _val)
 Pushes a value onto the stack.
dataType pop ()
 Pops a value off the stack.
dataType const & peek ()
 Returns whatever value is on the top of the stack without removing it from the stack.
size_t count () const
 Indicates the number of items on the stack.
void empty ()
 Empties the stack.

Private Member Functions

void setSize (size_t _size)
 Sets the stack size to the given size.

Private Attributes

size_t m_stepSize
 The step size for which to increase the stack size by.
dataType * m_bottom
 The actual stack itself.
dataType * m_top
 The pointer to the current position in the stack.
size_t m_size
 The size of the stack.
size_t m_origSize
 The original size of the stack (used on an empty() call to reset things to defaults).


Detailed Description

template<class dataType>
class CrissCross::Data::DStack< dataType >

A dynamic stack implementation.

Constructor & Destructor Documentation

DStack ( size_t  _size = -1  ) 

The constructor.

Parameters:
_size The step size to use.


Member Function Documentation

size_t count (  )  const

Indicates the number of items on the stack.

Returns:
Number of items on the stack.

void empty (  ) 

Empties the stack.

If pointers are stored in the stack, they must be freed manually via a series of pop() and delete or free() calls.

dataType const& peek (  ) 

Returns whatever value is on the top of the stack without removing it from the stack.

Returns:
The topmost value on the stack.

dataType pop (  )  [inline]

Pops a value off the stack.

Returns:
The topmost value on the stack.

void push ( dataType  _val  )  [inline]

Pushes a value onto the stack.

Parameters:
_val The value to put on the stack.

void setSize ( size_t  _size  )  [private]

Sets the stack size to the given size.

Parameters:
_size The size to resize to.


Generated on Sun Feb 8 11:10:00 2009 for CrissCross by  doxygen 1.5.8