File:  [parser3project] / parser3 / src / include / pa_stack.h
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Wed Mar 7 13:54:46 2001 UTC (25 years, 4 months ago) by paf
Branches: MAIN
CVS tags: HEAD
fixed rwcontext of {} params up

/*
  $Id: pa_stack.h,v 1.3 2001/03/07 13:54:46 paf Exp $
*/

#ifndef PA_STACK_H
#define PA_STACK_H

#include "pa_array.h"

class Stack : public Array {
public:

	Stack(Pool& apool) : Array(apool), ftop(0) {
	}

	void push(Item *item) {
		if(ftop<size()) // cell is already allocated?
			put(ftop, item); // use it
		else
			*this+=item; // append it
		ftop++;
	}
	Item *pop() {
		return get(--ftop);
	}

	Item *operator [] (int top_offset) {
		return get(ftop-top_offset-1);
	}

	int top() { return ftop-1; }

private:

	// deepest used index
	int ftop;

};

#endif

E-mail: