Annotation of parser3/src/include/pa_stack.h, revision 1.1

1.1     ! paf         1: /*
        !             2:   $Id: pa_array.h,v 1.16 2001/02/21 15:26:32 paf Exp $
        !             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: 
        !            13:        Stack(Pool& apool) : Array(apool), top(0) {
        !            14:        }
        !            15: 
        !            16:        void push(Item *item) {
        !            17:                if(top<size()) // cell is already allocated?
        !            18:                        put(top, item); // use it
        !            19:                else
        !            20:                        *this+=item; // append it
        !            21:                top++;
        !            22:        }
        !            23:        Item *pop() {
        !            24:                return get(--top);
        !            25:        }
        !            26: 
        !            27:        Item *operator [] (int top_offset) {
        !            28:                return get(top-top_offset-1);
        !            29:        }
        !            30: 
        !            31: private:
        !            32: 
        !            33:        // deepest used index
        !            34:        int top;
        !            35: 
        !            36: };
        !            37: 
        !            38: #endif

E-mail: