standard-data-structures
Version:
A collection of standard data-structures for node and browser
38 lines (37 loc) • 890 B
TypeScript
/**
* A mutable MAX HEAP data-structure.
* It can also work as a min heap by inverting the `gt` parameter.
*/
export declare class MaxHeap<A> {
private readonly gt;
/**
* Creates a new [[MaxHeap]] data structure.
*/
static of<A>(gt: (a: A, b: A) => boolean): MaxHeap<A>;
/**
* Creates a new MaxHeap that works with numbers
*/
static readonly numbers: MaxHeap<number>;
private readonly stack;
private constructor();
/**
* Returns the size of the heap
*/
readonly length: number;
/**
* Returns the top most element on the heap
*/
readonly peek: A | undefined;
/**
* Remove the top element from heap.
*/
pop(): A | undefined;
/**
* Adds a new element to the heap
*/
push(element: A): void;
private areValid;
private heapD;
private heapU;
private swap;
}