// EventList.h: interface for the EventList class.
//
//////////////////////////////////////////////////////////////////////

#ifndef __ATALANTA_STACK_H__
#define __ATALANTA_STACK_H__

#include "Gate.h"

namespace atalantadll {
	class Stack
	{
		int maxCount;
		int count;
		Gate **stackData;

	public:
		Stack(int maxCount):maxCount(maxCount),count(0) {stackData=new Gate*[maxCount];};
		Stack(const Stack& source) 
		{
			count=source.count;
			maxCount=source.maxCount;
			stackData=new Gate*[maxCount];
			memcpy(stackData,source.stackData,sizeof(Gate)*count);
		}
		void push(Gate *gate) {stackData[count++]=gate;};
		Gate* pop() {return stackData[--count];};
		void clear() {count=0;};
		bool isEmpty() {return count==0;};
		void deleteItem(int i) {stackData[i]=stackData[--count];};
		int getCount() {return count-1;};
		void setCount(int i) {count=i+1;};
		void copyFrom(Stack *src) {
			this->clear();
			for(int i = 0; i <= src->getCount(); i++) { this->push((*src)[i]); }
		}

		Gate*&  operator[](const int index) {return stackData[index];};

		void resetFreach() {for(int i=0;i<count;i++) stackData[i]->freach=false;};

	};
}
#endif //__ATALANTA_STACK_H__
