#ifndef __UNBOUNDEDSTACK_HPP #define __UNBOUNDEDSTACK_HPP #include "unbounded.hpp" #include "stack.hpp" template class UnboundedStack : public Stack { public: UnboundedStack(); UnboundedStack(const Stack &s); UnboundedStack& 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; void clear(); protected: class UCursor_rep : public Stack::Cursor_rep { public: UCursor_rep *prev,*next; const UnboundedStack *stack; int currentIndex, nextIndex; ~UCursor_rep(); int isDone() const; const Item& currentItem() const; void advance(); }; friend class UCursor_rep; Cursor_rep *makeCursorRep() const; virtual int cursor_isDone(const UCursor_rep *c) const; virtual const Item& cursor_currentItem(const UCursor_rep *c) const; virtual void cursor_advance(UCursor_rep *c) const; virtual void cursor_unlink(UCursor_rep *c) const; virtual void copyTo(Stack &s) const; private: Unbounded rep; UCursor_rep *firstCursor; }; #include "unboundedstack.cpp" #endif