/** * Stores a collection of objects in such a way that the highest priority element is always at front. * * The element type `T` can has method `compare(a, b)` and/or method `valueOf()`. */ export declare class BinaryHeap { private readonly compare; private content; /** * @param compareFn - Function to compare the priority of `a` and `b`. Returns positive if `a` has higher * priority than `b`; returns negitave if `b` has higer priority than `a`. * If this parameter is omitted, use `T.compare()` if exist, * otherwise native number/string comparation. */ constructor(compareFn?: (a: T, b: T) => number); /** * Adds an element into the collection and return the new size of the collection. */ enqueue(element: T): number; /** * Alias of `enqueue` */ push(element: T): number; /** * Returns the element at the front of the collection and removes it from the collection. */ dequeue(): T | undefined; /** * Alias of `dequeue` */ pop(): T | undefined; /** * Remove the element at the end of the collection and retures it. * * Note: heap is not sorted, the element at the end may not be the lowest priority. */ pollLast(): T | undefined; /** * Returns the element at the front of the collection without removing it. */ peek(): T | undefined; readonly size: number; /** * Removes all elements from the collection. */ clear(): void; /** * Brings a value up until its parent is greater than it. */ private float; /** * Moves a value downward until it is greater than its children. */ private sink; }