import { Comparator } from './utils/comparator'; export declare class Heap { private _heap; private _comparator; /** * Creates a new instance of Heap. * * @param comparator The comparator function to use. (Optional) */ constructor(comparator?: Comparator); /** * Returns the number of elements in the heap. * * @timeComplexity `O(1)` */ size(): number; /** * Returns true if the heap is empty, false otherwise. * * @timeComplexity `O(1)` */ isEmpty(): boolean; /** * Returns the top element of the heap without removing it. * * @timeComplexity `O(1)` * * @returns Returns the top element of the heap or undefined if * the heap is empty. */ peek(): T | void; /** * Adds elements to the heap. * * @timeComplexity `O(k * log(n))` where `k` is the number of items to add. * * @param items The elements to add to the heap. */ push(...items: T[]): void; /** * Removes the top element from the heap and returns it. * * @timeComplexity `O(log(n))` * * @returns The top element of the heap or undefined if * the heap is empty. */ pop(): T | undefined; /** * Clears the heap. * * @timeComplexity `O(1)` */ clear(): void; /** * Clones the heap. * * @timeComplexity `O(n)` */ clone(): Heap; /** * Converts the heap to a sorted array. * * @timeComplexity `O(n * log(n))` */ toArray(): T[]; /** * Builds a heap from the given array. * * @param array The array to build the heap from. * @param comparator The comparator function to use. (Optional) * * @timeComplexity `O(n * log(n))` * * @returns The heap built from the given array. */ static fromArray(array: T[], comparator?: Comparator): Heap; /** * Moves the element at the given index down the heap to its * correct position. * * @param index The index of the element to move down. */ private _heapifyDown; /** * Moves the element at the given index up the heap to its correct position. * * @param index The index of the element to move up. */ private _heapifyUp; private _getParentIndex; private _getLeftChildIndex; private _getRightChildIndex; }