Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

stack< stack_type, stack_max > Class Template Reference

A stack template. More...

#include <stack.h>

Collaboration diagram for stack< stack_type, stack_max >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 stack (void)
bool empty (void)
void reset (void)
void push (stack_type &val)
stack_type pop (void)

Private Attributes

stack_type stak [stack_max]
unsigned int ix

Detailed Description

template<class stack_type, unsigned int stack_max>
class stack< stack_type, stack_max >

A stack template.

This template is instantiated with the stack type and the stack size. For example:

stack<my_type, 128> my_stack;
creates a stack that can hold up to 128 elements of my_type.

Definition at line 31 of file stack.h.


Constructor & Destructor Documentation

template<class stack_type, unsigned int stack_max>
stack< stack_type, stack_max >::stack void   )  [inline]
 

Definition at line 38 of file stack.h.

References stack< stack_type, stack_max >::ix.

00038 { ix = stack_max; }


Member Function Documentation

template<class stack_type, unsigned int stack_max>
bool stack< stack_type, stack_max >::empty void   )  [inline]
 

Definition at line 40 of file stack.h.

References stack< stack_type, stack_max >::ix.

00040 { return ix == stack_max; }

template<class stack_type, unsigned int stack_max>
stack_type stack< stack_type, stack_max >::pop void   )  [inline]
 

Definition at line 51 of file stack.h.

References stack< stack_type, stack_max >::ix, and stack< stack_type, stack_max >::stak.

00052     {
00053         stack_type val;
00054 
00055         assert( ix < stack_max );
00056         val = stak[ix];
00057         ix++;
00058         return val;
00059     }

template<class stack_type, unsigned int stack_max>
void stack< stack_type, stack_max >::push stack_type &  val  )  [inline]
 

Definition at line 44 of file stack.h.

References stack< stack_type, stack_max >::ix, and stack< stack_type, stack_max >::stak.

00045     {
00046         assert( ix > 0 );
00047         ix--;
00048         stak[ ix ] = val;
00049     }

template<class stack_type, unsigned int stack_max>
void stack< stack_type, stack_max >::reset void   )  [inline]
 

Definition at line 42 of file stack.h.

References stack< stack_type, stack_max >::ix.

00042 { ix = stack_max; }


Member Data Documentation

template<class stack_type, unsigned int stack_max>
unsigned int stack< stack_type, stack_max >::ix [private]
 

Definition at line 35 of file stack.h.

Referenced by stack< stack_type, stack_max >::empty(), stack< stack_type, stack_max >::pop(), stack< stack_type, stack_max >::push(), stack< stack_type, stack_max >::reset(), and stack< stack_type, stack_max >::stack().

template<class stack_type, unsigned int stack_max>
stack_type stack< stack_type, stack_max >::stak[ stack_max ] [private]
 

Definition at line 34 of file stack.h.

Referenced by stack< stack_type, stack_max >::pop(), and stack< stack_type, stack_max >::push().


The documentation for this class was generated from the following file:
Generated on Wed Mar 31 21:16:09 2004 for Data Structures for a VHDL Compiler by doxygen 1.3.3