#ifndef BOUNDED_STACK_H #define BOUNDED_STACK_H #include "BoundedStackEmptyException.h" /** * Interface for a bounded stack: A collection of objects that are inserted * and removed according to the last-in first-out principle, but with * overflow handled by the removal of the least-recently accessed item. */ class BoundedStack { public: /** * Returns number of objects in the stack. */ virtual size_t size() const =0; /** * Returns true if the stack is empty, false otherwise. */ virtual bool empty() const =0; /** * Returns constant reference to the top object in the stack. * Throws BoundedStackEmptyException if the stack is empty. */ virtual const string& top() const throw(BoundedStackEmptyException) =0; /** * Inserts an object at the top of the stack, making room if * necessary by removing the item at the bottom of the stack. */ virtual void push(const string& obj) =0; /** * Removes the top object from the stack. * Throws BoundedStackEmptyException if the stack is empty. */ virtual void pop() throw(BoundedStackEmptyException) =0; /** * Virtual Destructor */ virtual ~BoundedStack() {}; }; #endif