#include "stack.h"
Public Member Functions | |
| Stack () | |
| ~Stack () | |
| int | size () |
| bool | isEmpty () |
| void | push (ElemType elem) |
| ElemType | pop () |
| ElemType | peek () |
| void | clear () |
The constructor initializes a new empty stack.
The destructor deallocates storage associated with this stack.
| int Stack< ElemType >::size | ( | ) |
This member function returns the number of elements in this stack.
| bool Stack< ElemType >::isEmpty | ( | ) |
This member function returns true if this stack contains no elements, false otherwise.
| void Stack< ElemType >::push | ( | ElemType | elem | ) |
This member function pushes the specified element onto this stack. That element becomes the top element on the stack. The stack's size increases by one.
| ElemType Stack< ElemType >::pop | ( | ) |
This member function removes the top element from this stack and returns it. The top element is the one that was last pushed. The stack's size decreases by one. This function raises an error if called on an empty stack.
| ElemType Stack< ElemType >::peek | ( | ) |
This member function returns the value of top element from this stack, without removing it. The stack's size is unchanged. Raises an error if peek is called on an empty stack.
| void Stack< ElemType >::clear | ( | ) |
This member function removes all elements from this stack. The stack is made empty and will have size() = 0.
1.5.1