00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __TOOLBOX_STACK_H
00010 #define __TOOLBOX_STACK_H
00011
00012
00013 namespace toolbox
00014 {
00034 template <class ITEMTYPE> class ContainingStack
00035 {
00036 private:
00037
00041 long Count;
00042
00043 #ifdef _TOOLBOX_TEST
00044
00047 static int InstanceCount;
00048 #endif
00049
00053 ITEMTYPE * Top;
00054
00055 public:
00056
00060 ContainingStack();
00061
00066 virtual ~ContainingStack();
00067
00073 bool Delete();
00074
00079 void DeleteAll();
00080
00085 inline long GetCount() const;
00086
00090 inline bool IsEmpty() const;
00091
00096 inline ITEMTYPE * Peek() const;
00097
00103 ITEMTYPE * Pop();
00104
00111 void PopAll();
00112
00117 void Push(ITEMTYPE * NewItem);
00118
00119 #ifdef _TOOLBOX_TEST
00120
00126 static void RunTestSuite(int * performedTests, int * failedTests);
00127 #endif
00128 };
00129
00130
00143 template <class ITEMTYPE> class ContainingStackItem
00144 {
00145 friend class ContainingStack<ITEMTYPE>;
00146
00147 private:
00148
00149 #ifdef _TOOLBOX_TEST
00150
00153 static int InstanceCount;
00154 #endif
00155
00160 ITEMTYPE * NextItem;
00161
00162 public:
00163
00167 ContainingStackItem();
00168
00172 virtual ~ContainingStackItem();
00173
00174 #ifdef _TOOLBOX_TEST
00175
00181 static void RunTestSuite(int * performedTests, int * failedTests);
00182 #endif
00183 };
00184
00185
00203 class PointeredStack : public ContainingStack<PointeredStackItem>
00204 {
00205 private:
00206
00207 #ifdef _TOOLBOX_TEST
00208
00211 static int InstanceCount;
00212 #endif
00213
00214 public:
00215
00219 PointeredStack();
00220
00227 virtual ~PointeredStack();
00228
00229 #ifdef _TOOLBOX_TEST
00230
00236 static void RunTestSuite(int * performedTests, int * failedTests);
00237 #endif
00238 };
00239
00240
00253 class PointeredStackItem : public ContainingStackItem<PointeredStackItem>
00254 {
00255 private:
00256
00260 void * Data;
00261
00262 #ifdef _TOOLBOX_TEST
00263
00266 static int InstanceCount;
00267 #endif
00268
00269 public:
00270
00274 PointeredStackItem();
00275
00279 virtual ~PointeredStackItem();
00280
00285 inline void * GetData() const;
00286
00287 #ifdef _TOOLBOX_TEST
00288
00294 static void RunTestSuite(int * performedTests, int * failedTests);
00295 #endif
00296
00301 inline void SetData(void * Data);
00302 };
00303 }
00304
00305
00306 #endif