summaryrefslogtreecommitdiff
path: root/indra/llcommon/lldepthstack.h
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2007-01-02 08:33:20 +0000
committerJames Cook <james@lindenlab.com>2007-01-02 08:33:20 +0000
commit420b91db29485df39fd6e724e782c449158811cb (patch)
treeb471a94563af914d3ed3edd3e856d21cb1b69945 /indra/llcommon/lldepthstack.h
Print done when done.
Diffstat (limited to 'indra/llcommon/lldepthstack.h')
-rw-r--r--indra/llcommon/lldepthstack.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/indra/llcommon/lldepthstack.h b/indra/llcommon/lldepthstack.h
new file mode 100644
index 0000000000..6b259ec9b0
--- /dev/null
+++ b/indra/llcommon/lldepthstack.h
@@ -0,0 +1,81 @@
+/**
+ * @file lldepthstack.h
+ * @brief Declaration of the LLDepthStack class
+ *
+ * Copyright (c) 2001-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#ifndef LL_LLDEPTHSTACK_H
+#define LL_LLDEPTHSTACK_H
+
+#include "linked_lists.h"
+
+template <class DATA_TYPE> class LLDepthStack
+{
+private:
+ LLLinkedList<DATA_TYPE> mStack;
+ U32 mCurrentDepth;
+ U32 mMaxDepth;
+
+public:
+ LLDepthStack() : mCurrentDepth(0), mMaxDepth(0) {}
+ ~LLDepthStack() {}
+
+ void setDepth(U32 depth)
+ {
+ mMaxDepth = depth;
+ }
+
+ U32 getDepth(void) const
+ {
+ return mCurrentDepth;
+ }
+
+ void push(DATA_TYPE *data)
+ {
+ if (mCurrentDepth < mMaxDepth)
+ {
+ mStack.addData(data);
+ mCurrentDepth++;
+ }
+ else
+ {
+ // the last item falls off stack and is deleted
+ mStack.getLastData();
+ mStack.deleteCurrentData();
+ mStack.addData(data);
+ }
+ }
+
+ DATA_TYPE *pop()
+ {
+ DATA_TYPE *tempp = mStack.getFirstData();
+ if (tempp)
+ {
+ mStack.removeCurrentData();
+ mCurrentDepth--;
+ }
+ return tempp;
+ }
+
+ DATA_TYPE *check()
+ {
+ DATA_TYPE *tempp = mStack.getFirstData();
+ return tempp;
+ }
+
+ void deleteAllData()
+ {
+ mCurrentDepth = 0;
+ mStack.deleteAllData();
+ }
+
+ void removeAllNodes()
+ {
+ mCurrentDepth = 0;
+ mStack.removeAllNodes();
+ }
+};
+
+#endif