Annotation of parser3/src/include/pa_stack.h, revision 1.4
1.1 paf 1: /*
1.4 ! paf 2: $Id: pa_stack.h,v 1.3 2001/03/07 13:54:46 paf Exp $
1.1 paf 3: */
4:
5: #ifndef PA_STACK_H
6: #define PA_STACK_H
7:
8: #include "pa_array.h"
9:
10: class Stack : public Array {
11: public:
12:
1.2 paf 13: Stack(Pool& apool) : Array(apool), ftop(0) {
1.1 paf 14: }
15:
16: void push(Item *item) {
1.2 paf 17: if(ftop<size()) // cell is already allocated?
18: put(ftop, item); // use it
1.1 paf 19: else
20: *this+=item; // append it
1.2 paf 21: ftop++;
1.1 paf 22: }
23: Item *pop() {
1.2 paf 24: return get(--ftop);
1.1 paf 25: }
26:
1.4 ! paf 27: int top_index() { return ftop-1; }
! 28: Item *top_value() { return get(top_index()); }
1.2 paf 29:
1.1 paf 30: private:
31:
32: // deepest used index
1.2 paf 33: int ftop;
1.1 paf 34:
35: };
36:
37: #endif
E-mail: