UNPKG

stl-kit

Version:

A modern JavaScript & TypeScript standard template library (STL) for data structures and algorithms. Includes high-performance implementations of Stack, Queue, Deque, Linked List, Vector, Set, Map, Tree, Heap, and Graph — inspired by C++ STL. Designed for

31 lines (29 loc) 1.19 kB
type Factory<T, A extends unknown[]> = (...args: A) => T; interface StackOptions<T, A extends unknown[]> { initValues?: T[]; factory?: Factory<T, A>; } declare class Stack<T, A extends unknown[] = unknown[]> { #private; constructor({ initValues, factory }?: StackOptions<T, A>); [Symbol.iterator](): IterableIterator<T>; rbegin(): IterableIterator<T>; begin(): IterableIterator<T>; push(value: T): void; pop(): T | undefined; emplace(...args: A): void; isEmpty(): boolean; clear(): void; toArray(): T[]; assign(count: number, value: T): void; assign(values: T[], start?: number, end?: number): void; forEach(callback: (value: T, index: number, stack: Stack<T, A>) => void | false, thisArg?: unknown): void; peek(): T | undefined; clone(deepCloneFn?: (val: T) => T): Stack<T, A>; get length(): number; get top(): T | undefined; set top(val: T); static equals<U, V extends unknown[] = unknown[]>(stack1: Stack<U, V>, stack2: Stack<U, V>, comparator?: (a: U, b: U) => boolean): boolean; static swap<U, V extends unknown[] = unknown[]>(stack1: Stack<U, V>, stack2: Stack<U, V>): void; } export { Stack };