00001
00002
00003 #ifndef STACK_H
00004 #define STACK_H
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 };
00061
00062
00063 #endif