export type HeapCompareFn = (a: T, b: T) => number; /** * @license MIT * @copyright 2024 Thinh Trinh Duc * * @class */ export declare class Heap { #private; /** * * @param values New elements to add to the Heap. * @param compareFn Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. */ constructor(values?: T[], compareFn?: HeapCompareFn); get size(): number; get root(): T; /** * * @param values New elements to add to the Heap. * @param compareFn Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. */ static fromArray(values?: T[], compareFn?: HeapCompareFn): Heap; /** * Get left child's index of the provided index. * @param i index of the node */ static getLeftChildIndex(i: number): number; /** * Get right child's index of the provided index. * @param i index of the node */ static getRightChildIndex(i: number): number; /** * Get parent's index of the provided index. * @param i index of the node */ static getParentIndex(i: number): number; /** * Inserts new elements to the Heap. * if only single value is add the complexity is log(N) * otherwise the complexity is log(N) * @param values New elements to add to the Heap. */ insert(...values: T[]): this; /** * Checks if an array is a valid heap. */ isValid(i?: number): boolean; /** * Remove the top element of a heap and returns it * Return `undefined` if heap is empty. */ extractRoot(): T | undefined; toArray(): T[]; } //# sourceMappingURL=heap.d.ts.map