dune-common  2.2.0
finitestack.hh
Go to the documentation of this file.
00001 #ifndef DUNE_FINITE_STACK_HH
00002 #define DUNE_FINITE_STACK_HH
00003 
00008 #warning This file is deprecated and will be removed after the release of dune-common-2.2. \
00009          Please use std::stack<Dune::ReservedVector> instead of FiniteStack.
00010   
00011 #include <stack>
00012 
00013 #include <dune/common/exceptions.hh>
00014 #include <dune/common/reservedvector.hh>
00015 
00016 namespace Dune {
00017   
00037   template<class T, int n>
00038   class FiniteStack 
00039        : public std::stack<T, Dune::ReservedVector<T,n> >
00040   {
00041   public :
00042 
00044         bool full () const
00045         {
00046           return this->size()>=n;
00047         }
00048 
00052         T pop ()
00053         {
00054 #ifndef NDEBUG
00055             if (this->empty())
00056                DUNE_THROW(Dune::RangeError, "trying to call pop() on an empty FiniteStack");
00057 #endif
00058             T tmp = this->top();
00059             this->std::stack<T,Dune::ReservedVector<T,n> >::pop();
00060             return tmp;
00061         }
00062        
00063   };
00064 
00065 }
00066 
00068 
00069 #endif