UNPKG

dastal

Version:

Data Structures & Algorithms implementations

34 lines (33 loc) 1.16 kB
import { LinkedNode } from 'src/list'; import { BinaryTreeNode } from 'src/tree/binaryTreeNode'; import { CompareFn } from '..'; /** * @internal */ export declare function bubbleUp<T>(index: number, compareFn: CompareFn<T>, array: Array<T>): void; /** * @internal */ export declare function heapify<T>(compareFn: CompareFn<T>, array: T[]): void; /** * @internal */ export declare function mergeKSorted<T>(compareFn: CompareFn<T>, lists: LinkedNode<T>[]): LinkedNode<T>; /** * @internal */ export declare function sinkDown<T>(index: number, compareFn: CompareFn<T>, array: Array<T>): void; /** * See: https://en.wikipedia.org/wiki/Skew_heap#Merging_two_heaps * * @param compareFn - A function used to determine the order of the heap. * * It is expected to return: * - A negative value if first argument < second argument * - Zero if first argument == second argument * - A positive value if first argument > second argument * @param heaps - An iterable of heaps to merge * * @returns The new heap */ export declare function skewMerge<T>(compareFn: CompareFn<T>, heaps: (BinaryTreeNode<T> | undefined)[]): BinaryTreeNode<T> | undefined;