lldepthstack.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLDEPTHSTACK_H
00033 #define LL_LLDEPTHSTACK_H
00034 
00035 #include "linked_lists.h"
00036 
00037 template <class DATA_TYPE> class LLDepthStack
00038 {
00039 private:
00040         LLLinkedList<DATA_TYPE> mStack;
00041         U32                                             mCurrentDepth;
00042         U32                                             mMaxDepth;
00043 
00044 public:
00045         LLDepthStack() : mCurrentDepth(0), mMaxDepth(0) {}
00046         ~LLDepthStack() {}
00047 
00048         void setDepth(U32 depth)
00049         {
00050                 mMaxDepth = depth;
00051         }
00052 
00053         U32 getDepth(void) const
00054         {
00055                 return mCurrentDepth;
00056         }
00057 
00058         void push(DATA_TYPE *data)
00059         { 
00060                 if (mCurrentDepth < mMaxDepth)
00061                 {
00062                         mStack.addData(data); 
00063                         mCurrentDepth++;
00064                 }
00065                 else
00066                 {
00067                         // the last item falls off stack and is deleted
00068                         mStack.getLastData();
00069                         mStack.deleteCurrentData();     
00070                         mStack.addData(data);
00071                 }
00072         }
00073         
00074         DATA_TYPE *pop()
00075         { 
00076                 DATA_TYPE *tempp = mStack.getFirstData(); 
00077                 if (tempp)
00078                 {
00079                         mStack.removeCurrentData(); 
00080                         mCurrentDepth--;
00081                 }
00082                 return tempp; 
00083         }
00084         
00085         DATA_TYPE *check()
00086         { 
00087                 DATA_TYPE *tempp = mStack.getFirstData(); 
00088                 return tempp; 
00089         }
00090         
00091         void deleteAllData()
00092         { 
00093                 mCurrentDepth = 0;
00094                 mStack.deleteAllData(); 
00095         }
00096         
00097         void removeAllNodes()
00098         { 
00099                 mCurrentDepth = 0;
00100                 mStack.removeAllNodes(); 
00101         }
00102 };
00103 
00104 #endif

Generated on Fri May 16 08:32:02 2008 for SecondLife by  doxygen 1.5.5