Class Stack<X> provides a minimal LIFO stack of elements of type X.
See library Deque for mixed LIFO/FIFO behavior.
Example:
motoko name=initialize
import Stack "mo:base/Stack";
let stack = Stack.Stack<Nat>(); // create a stack| Runtime   | Space     |
|-----------|-----------|
| O(1) | O(1) |
public func push(x : T)Push an element on the top of the stack.
Example:
motoko include=initialize
stack.push(1);
stack.push(2);
stack.push(3);
stack.peek(); // examine the top most element| Runtime   | Space     |
|-----------|-----------|
| O(1) | O(1) |
public func isEmpty() : BoolTrue when the stack is empty and false otherwise.
Example:
motoko include=initialize
stack.isEmpty();| Runtime   | Space     |
|-----------|-----------|
| O(1) | O(1) |
public func peek() : ?TReturn (without removing) the top element, or return null if the stack is empty.
Example:
motoko include=initialize
stack.push(1);
stack.push(2);
stack.push(3);
stack.peek();| Runtime   | Space     |
|-----------|-----------|
| O(1) | O(1) |
public func pop() : ?TRemove and return the top element, or return null if the stack is empty.
Example:
motoko include=initialize
stack.push(1);
ignore stack.pop();
stack.isEmpty();| Runtime   | Space     |
|-----------|-----------|
| O(1) | O(1) |