ts-data.stack
v1.0.6
Published
The Stack (LIFO) data structure in TypeScript.
Maintainers
Readme
ts-data.stack
A stack implemented in TypeScript.
Installation
$ npm install ts-data.stackUsage
import Stack from "ts-data.stack";
let stack = new Stack<number>();
stack.push(3);
stack.push(7);
stack.count(); // 2
stack.isEmpty(); // false
stack.peek(); // 7
stack.pop(); // 7
stack.pop(); // 3
stack.isEmpty(); // trueDocumentation
Stack<TData>()
A stack containing TData types. The constructor takes no arguments.
count(): number
Get the count of items in the stack.
isEmpty(): boolean
True if the stack is empty, false if it contains any elements.
push(value: TData): void
Pushes value to the top of the stack.
pop(): TData
Pop the top value off of the stack and return it.
peek(): TData
Get the top value of the stack without removing it from the stack.
License
Licensed under the MIT License.
