The type of data the stack holds
Creates a stack.
If items is not null, it will push items onto the stack:
const stack1 = new Stack<number>(1, 2, 3);
const stack2 = new Stack<number>().push(1).push(2).push(3);Both stacks will be equal.
The items to push onto the stack
The number of items pushed onto the stack.
Returns a value off the top of the stack without modifying the stack.
const stack = new Stack(1, 2, 3);
console.log(stack.peek()); // 3
console.log(stack.size); // 3
The value off the top of the stack
Pops a value off the top of the stack, and then removes it.
const stack = new Stack(1, 2, 3);
console.log(stack.pop()); // 3
console.log(stack.size); // 2
The value off the top of the stack
Pushes a value on to the top of the stack.
Since push returns this, multiple push commands can be chained:
const stack = new Stack<number>();
stack.push(1).push(2).push(3);
The value to push on to the top of the stack
This stack
Returns an array representation of the stack.
An array representation of the stack
Returns a string representation of the stack.
A string representation of the stack
Creates a stack.
If items is not null, it will push items onto the stack:
const stack1 = Stack<number>.create(1, 2, 3);
const stack2 = Stack<number>.create().push(1).push(2).push(3);Both stacks will be equal.
The type of data the stack holds
The items to push onto the stack
A new stack
Generated using TypeDoc
A last-in-first-out (LIFO) data structure.
For more information about stacks: https://en.wikipedia.org/wiki/Stack_(abstract_data_type).