UNPKG

lgrthms

Version:

Algorithms and data structures for your JavaScript and TypeScript projects 🧑‍💻

20 lines (19 loc) 537 B
declare type CompareMethod = 'isLessThan' | 'isGreaterThan'; export declare class Heap<T = any> { private heap; private readonly comparator; private readonly method; constructor(method: CompareMethod, compareFn?: (a: T, b: T) => number); get size(): number; build(array: T[]): void; insert(value: T): T; peek(): T | undefined; toArray(): T[]; extract(): T | undefined; private siftDown; private siftUp; private swap; private getChildIndex; private getParentIndex; } export {};