UNPKG

@coderbaba/stl-js

Version:

STL data structures for JavaScript

26 lines (19 loc) 379 B
class Stack<T> { private items: T[] = []; push(item: T): void { this.items.push(item); } pop(): T | undefined { return this.items.pop(); } peek(): T | undefined { return this.items[this.items.length - 1]; } isEmpty(): boolean { return this.items.length === 0; } size(): number { return this.items.length; } } export default Stack;