SimpleCxxLib
packageclass Stack<ValueType>
push
(add to top) and pop
(remove from top).
Constructor | |
Initializes a new empty stack. | |
Methods | |
Removes all elements from this stack. | |
Returns true if this stack contains no elements. | |
Returns the value of top element from this stack, without removing it. | |
Removes the top element from this stack and returns it. | |
Pushes the specified value onto this stack. | |
Returns the number of values in this stack. | |
Converts the stack to a printable string representation. |
Stack();
Usage:
Stack<ValueType> stack; Stack<ValueType> stack = { bottomValue, middleValue, topValue };
int size() const;
Usage:
int n = stack.size();
bool isEmpty() const;
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() const; ValueType & top();
top
, in which case it returns the value
by reference.
Usage:
ValueType top = stack.peek();
string toString();
Usage:
string str = stack.toString();