Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

util::Stack< T > Class Template Reference

#include <Stack.h>

Inheritance diagram for util::Stack< T >:

util::List< T > util::Iterator< T > util::Object List of all members.

Detailed Description

template<class T>
class util::Stack< T >

Stack is a data structure that is accessed from one end.

Items are "pushed" on the top of the stack and "popped" out of it. In other words, stack is a FILO (first-in-last-out) buffer.


Public Methods

 Stack (int capacity=16, int blockSize=16)
 Create a stack with the given initial capacity and block size.

 Stack (const List< T > &other)
 Create a copy of any list as a stack.

Stack & operator= (const List< T > &other)
 Copy any list to a stack.

void push (T element)
 Push an element on the top of the stack.

pop ()
 Pop the element on the top of the stack.

T & peek ()
 See what's on the top of the stack without popping an element.

const T & peek () const
 See what's on the top of the stack without popping an element.


Member Function Documentation

template<class T>
const T& util::Stack< T >::peek   const [inline]
 

See what's on the top of the stack without popping an element.

Const version.

Returns:
the most recently added element

template<class T>
T& util::Stack< T >::peek   [inline]
 

See what's on the top of the stack without popping an element.

Returns:
the most recently added element

template<class T>
T util::Stack< T >::pop   [inline]
 

Pop the element on the top of the stack.

The stack will shrink by one element, thus there must be at least one element in the stack before calling this method.


The documentation for this class was generated from the following file:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.