class Stack<ValueType>push (add to top) and pop
(remove from top).
| Constructor | |
| Stack() | Initializes a new empty stack. |
| Methods | |
| size() | Returns the number of values in this stack. |
| isEmpty() | Returns true if this stack contains no elements. |
| clear() | Removes all elements from this stack. |
| push(value) | Pushes the specified value onto this stack. |
| pop() | Removes the top element from this stack and returns it. |
| peek() | Returns the value of top element from this stack, without removing it. |
Stack();
Usage:
Stack<ValueType> stack;
int size();
Usage:
int n = stack.size();
bool isEmpty();
true if this stack contains no elements.
Usage:
if (stack.isEmpty()) . . .
void clear();
Usage:
stack.clear();
void push(ValueType value);
Usage:
stack.push(value);
ValueType pop();
Usage:
ValueType top = stack.pop();
ValueType peek(); ValueType & top();
top, in which case it returns the value
by reference.
Usage:
ValueType top = stack.peek();