/************************************************************ ** Maysa Peterson SE507 Formal Specifications ** ** Arila Attanosova CS AP Specifications for C+ ** ** March6, 1996 ** ************************************************************/ /************************************************************ ** APCS stack class ** ** ** ** Specifications for queue functions ** ** ** ** Any violation of a function's precondition will result in an error ** ** message followed by a call to abort. ** ************************************************************/ template class stack { public: /************************************************************ ** constructors/destructors - for initialing and finalizing data structure of** ** type queue ** ************************************************************/ stack( ); // construct empty queue stack(stack s); // copy constructor ~stack( ); // destructor - queue is destroyed /************************************************************ ** assignment - normal assignment via copying is been performed below ** ************************************************************/ stack operator = (stack righthandside); /************************************************************ ** accessors - "const" indicates that the original queue is not altered ** ************************************************************/ itemType top( ) const; // return top element (NO pop) /************************************************************ ** given stack is [a1, a2, ..., an] with n >= 1 ** ** function returns an ** ************************************************************/ bool isEmpty( ) const; // return true if empty, else false /************************************************************ ** function returns true if queue is empty, false otherwise ** ************************************************************/ int length( ) const; // return stack size in length /************************************************************ ** given queue is [a1, a2, ..., an] with n >= 0 ** ** function returns n ** ************************************************************/ /* modifying procedures defined below: */ push(itemType item ); // push item onto top of stack /************************************************************ ** precondition: stack is [a1, a2...an] with n >= 0 ** ** postcondition: stack is [a1, a2, ... an, item] ** ************************************************************/ pop( ); // pop top element /************************************************************ ** precondition: stack is [a1, a2, ... an] with n >= 1 ** ** postcondition: stack is [a1, a2, ... a(n-1)] ** ************************************************************/ pop( itemType item ); // combines pop and top /************************************************************ ** precondition: stack is [a1,a2,...an] with n >= 1 ** ** postcondition: stack is [a1,a2,...a(n-1)] and item == en ** ************************************************************/ makeEmpty( ); // make stack empty (no elements) /************************************************************ ** precondition: stack is [a1,a2,...an] with n >= 0 ** ** postcondition: stack is empty ** ************************************************************/ private: /* implementation will be supplied later */ };