#ifndef AG_STACK_H #define AG_STACK_H /* * The AGCLIB1 Class Library, Version 1.0 * Copyright (c) Parsifal Software, 2001. All Rights Reserved. * http://www.parsifalsoft.com */ #include "agbstk.h" template class AgStack : public AgCopyControl > { typedef AgStackBase StackBase; typedef AgCopyControl Base; typedef AgStack This; public: typedef AgContents Contents; AgStack(const int bufferSize = DEFAULT_BUFFER_SIZE) : Base(new StackBase(bufferSize)) {} AgStack(const AgContainerContents &x, int bufferSize = DEFAULT_BUFFER_SIZE) : Base(new StackBase(x, bufferSize)) {} AgStack(const This &s) : Base(s) {} ~AgStack() {} This &push(const Object &x) {kernel()->push(x); return *this;} Object pop() {return kernel()->pop();} const Object &top() const {return kernel()->top();} Object &top() {return kernel()->top();} int size() const { return kernel()->size();} This &reset() {kernel()->reset(); return *this;} const Contents contents() const {return Contents(*this);} This &operator = (const This &x) {Base::operator = (x); return *this;} This &operator = (const AgContainerContents &x) {*kernel() = x; return *this;} Object &operator [] (int x) {return kernel()->operator[] (x);} const Object &operator [] (int x) const {return kernel()->operator[] (x);} }; template AgStack &operator += (AgStack &s, const Container &c) { int n = c.size(); for (int i = 0; i < n; i++) s.push((Object &) c[i]); return s; } template int agABTHash(const AgStack &c, int hash) { return agABTHashContainer(c, hash); } template inline int agABTHash(const AgStack &c) { return agABTHashContainer(c, 0); } #endif