/** * Mnemonist Heap Typings * ======================= */ type HeapComparator = (a: T, b: T) => number; export default class Heap { // Members size: number; // Constructor constructor(comparator?: HeapComparator); // Methods clear(): void; push(item: T): number; peek(): T | undefined; pop(): T | undefined; replace(item: T): T | undefined; pushpop(item: T): T | undefined; toArray(): Array; consume(): Array; inspect(): any; // Statics static from( iterable: Iterable | {[key: string]: I}, comparator?: HeapComparator ): Heap; } export class MinHeap { // Members size: number; // Constructor constructor(comparator?: HeapComparator); // Methods clear(): void; push(item: T): number; peek(): T | undefined; pop(): T | undefined; replace(item: T): T | undefined; pushpop(item: T): T | undefined; toArray(): Array; consume(): Array; inspect(): any; // Statics static from( iterable: Iterable | {[key: string]: I}, comparator?: HeapComparator ): Heap; } export class MaxHeap { // Members size: number; // Constructor constructor(comparator?: HeapComparator); // Methods clear(): void; push(item: T): number; peek(): T | undefined; pop(): T | undefined; replace(item: T): T | undefined; pushpop(item: T): T | undefined; toArray(): Array; consume(): Array; inspect(): any; // Statics static from( iterable: Iterable | {[key: string]: I}, comparator?: HeapComparator ): Heap; } // Static helpers export function push(comparator: HeapComparator, heap: Array, item: T): void; export function pop(comparator: HeapComparator, heap: Array): T; export function replace(comparator: HeapComparator, heap: Array, item: T): T; export function pushpop(comparator: HeapComparator, heap: Array, item: T): T; export function heapify(comparator: HeapComparator, array: Array): void; export function consume(comparator: HeapComparator, heap: Array): Array; export function nsmallest(comparator: HeapComparator, n: number, values: Iterable): Array; export function nsmallest(n: number, values: Iterable): Array; export function nlargest(comparator: HeapComparator, n: number, values: Iterable): Array; export function nlargest(n: number, values: Iterable): Array;