Stack< T > Class Template Reference
 
 
 
Stack< T > Class Template Reference

This reference page is linked to from the following overview topics: Profiling Plug-in Performance, Tips and Tricks.


#include <stack.h>

Inheritance diagram for Stack< T >:
MaxHeapOperators

Class Description

template<class T>
class Stack< T >

A simple stack implementation.

Public Member Functions

const T &  operator[] (const int i) const
T &  operator[] (const int i)
void  Push (T *el)
void  Pop (T *el)
void  Pop ()
void  GetTop (T *el)
void  Clear ()
int  Count () const
int  Remove (int i)

Member Function Documentation

const T& operator[] ( const int  i ) const [inline]
                                                       { 
                        DbgAssert(s.Count()-i>0);
                        return s[s.Count()-i-1];
                        }
T& operator[] ( const int  i ) [inline]
                                           { 
                        DbgAssert(s.Count()-i>0);
                        return s[s.Count()-i-1];
                }
void Push ( T *  el ) [inline]
Remarks:
Pushes the specified element on the stack.
Parameters:
T *el

The item to push.
                                   { 
                        s.Append( 1, el );                      
                        }
void Pop ( T *  el ) [inline]
Remarks:
Pops an item off the stack.
Parameters:
T *el

The item popped off the stack is returned here.
                                  { 
                        DbgAssert( s.Count() ); 
                        *el = s[s.Count()-1];
                        s.Delete( s.Count()-1, 1 );                     
                        }
void Pop ( ) [inline]
Remarks:
Pops an item off the stack and discards it. The item is not returned.
                           { 
                        DbgAssert( s.Count() );                         
                        s.Delete( s.Count()-1, 1 );                     
                        }
void GetTop ( T *  el ) [inline]
Remarks:
Retrieves the item on top of the stack without altering the stack.
Parameters:
T *el

The top item is returned here.
                                     {
                        DbgAssert( s.Count() ); 
                        *el = s[s.Count()-1];
                        }
void Clear ( ) [inline]
Remarks:
Clears the stack. All items are deleted.
                             {
                        s.Delete(0,s.Count());                  
                        }
int Count ( ) const [inline]
Remarks:
Returns the number of item currently on the stack.
                                  {
                        return s.Count(); 
                        }
int Remove ( int  i ) [inline]
Remarks:
Removes the 'i-th' item from the stack.
Parameters:
int i

The item to remove from the stack.
Returns:
Returns the number of items left in the stack.
                                    {
                        assert(i<s.Count());
                        return s.Delete(s.Count()-1-i,1);
                        }