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

stack.h

Go to the documentation of this file.
00001 
00002 
00003 #ifndef STACK_H
00004 #define STACK_H
00005 
00006 
00007 /*===============================<o>=====================================
00008 
00009 Copyright 1996, 1997, 2004 Ian Kaplan, Bear Products International,
00010 www.bearcave.com.
00011 
00012 All Rights Reserved
00013 
00014 You may use this software in software components for which you do
00015 not collect money (e.g., non-commercial software).  All commercial
00016 use is reserved.
00017 
00018 ===============================<o>=====================================*/
00019 
00020 
00030 template <class stack_type, unsigned int stack_max>
00031 class stack {
00032 
00033 private:
00034     stack_type stak[ stack_max ];
00035     unsigned int ix;
00036 
00037 public:
00038     stack(void) { ix = stack_max; }
00039 
00040     bool empty(void) { return ix == stack_max; }
00041 
00042     void reset(void) { ix = stack_max; }
00043 
00044     void push( stack_type &val )
00045     {
00046         assert( ix > 0 );
00047         ix--;
00048         stak[ ix ] = val;
00049     }
00050 
00051     stack_type pop(void)
00052     {
00053         stack_type val;
00054 
00055         assert( ix < stack_max );
00056         val = stak[ix];
00057         ix++;
00058         return val;
00059     }
00060 };  // stack
00061 
00062 
00063 #endif

Generated on Wed Mar 31 21:15:55 2004 for Data Structures for a VHDL Compiler by doxygen 1.3.3