finitestack.hh
Go to the documentation of this file.00001 #ifndef DUNE_FINITE_STACK_HH
00002 #define DUNE_FINITE_STACK_HH
00003
00004 #include <dune/common/exceptions.hh>
00005
00006 namespace Dune {
00007
00027 template<class T, int n>
00028 class FiniteStack {
00029 public :
00030
00032 bool empty () const
00033 {
00034 return f==0;
00035 }
00036
00038 bool full () const
00039 {
00040 return f>=n;
00041 }
00042
00044 void push (const T& t)
00045 {
00046 s[f++] = t;
00047 }
00048
00050 T pop ()
00051 {
00052 return s[--f];
00053 }
00054
00056 T top () const
00057 {
00058 return s[f-1];
00059 }
00060
00062 int size () const
00063 {
00064 return f;
00065 }
00066
00068 FiniteStack ()
00069 {
00070 f = 0;
00071 }
00072
00073 private:
00074 T s[n];
00075 int f;
00076 };
00077
00078 }
00079
00081
00082 #endif