#ifndef __BOUNDEDSTACK_HPP #define __BOUNDEDSTACK_HPP #include "stack.hpp" #include "bounded.hpp" template class BoundedStack : public Stack { public: BoundedStack(); BoundedStack(const Stack &bs); BoundedStack& operator=(const Stack &s); virtual void push(const Item &i); virtual Item pop(); virtual Item top() const; virtual int isEmpty() const; virtual unsigned length() const; virtual void clear(); protected: class BCursor_rep : public Stack::Cursor_rep { public: BCursor_rep *prev,*next; const BoundedStack *stack; int currentIndex, nextIndex; ~BCursor_rep(); int isDone() const; const Item& currentItem() const; void advance(); }; friend class BCursor_rep; Cursor_rep *makeCursorRep() const; virtual int cursor_isDone(const BCursor_rep *c) const; virtual const Item& cursor_currentItem(const BCursor_rep *c) const; virtual void cursor_advance(BCursor_rep *c) const; virtual void cursor_unlink(BCursor_rep *c) const; virtual void copyTo(Stack &s) const; private: Bounded rep; BCursor_rep *firstCursor; }; #include "boundedstack.cpp" #endif