RemoteDrawingEngine: Reduce RP_READ_BITMAP result timeout.
[haiku.git] / src / bin / bfs_tools / lib / Stack.h
blob60a8e02c097a26ba289f0d2135eda6d7b1b92c2d
1 #ifndef STACK_H
2 #define STACK_H
3 /* Stack - a template stack class
4 **
5 ** Copyright 2001 pinc Software. All Rights Reserved.
6 */
9 #include <stdlib.h>
11 #include <SupportDefs.h>
14 template<class T> class Stack
16 public:
17 Stack()
19 fArray(NULL),
20 fUsed(0),
21 fMax(0)
25 ~Stack()
27 if (fArray)
28 free(fArray);
31 status_t Push(T value)
33 if (fUsed >= fMax)
35 fMax += 16;
36 fArray = (T *)realloc(fArray,fMax * sizeof(T));
37 if (fArray == NULL)
38 return B_NO_MEMORY;
40 fArray[fUsed++] = value;
41 return B_OK;
44 bool Pop(T *value)
46 if (fUsed == 0)
47 return false;
49 *value = fArray[--fUsed];
50 return true;
53 private:
54 T *fArray;
55 int32 fUsed;
56 int32 fMax;
59 #endif /* STACK_H */