File:  [parser3project] / parser3 / src / include / pa_stack.h
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Wed Feb 21 17:36:30 2001 UTC (25 years, 9 months ago) by paf
Branches: MAIN
CVS tags: HEAD
get put -1 [just compiled]

/*
  $Id: pa_stack.h,v 1.1 2001/02/21 17:36:30 paf Exp $
*/

#ifndef PA_STACK_H
#define PA_STACK_H

#include "pa_array.h"

class Stack : public Array {
public:

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

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

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

private:

	// deepest used index
	int top;

};

#endif

E-mail: