UNPKG

@thermopylae/lib.cache

Version:
51 lines (50 loc) 1.31 kB
import { Comparator, Undefinable } from '@thermopylae/core.declarations'; /** * @private */ declare const HEAP_NODE_IDX_SYM: unique symbol; /** * @private */ interface HeapNode { [HEAP_NODE_IDX_SYM]: number; } /** * @private */ declare class Heap<T extends HeapNode> { private readonly comparator; private readonly nodes; constructor(comparator: Comparator<T>); push(node: T): void; peek(): Undefinable<T>; pop(): Undefinable<T>; delete(node: T): void; heapifyUpdatedNode(node: T): void; clear(): void; get size(): number; static isPartOfHeap(node: HeapNode): boolean; private get root(); private set root(value); private get fartestRightNode(); private propagateUp; /** * Propagates `node` down the heap to preserve his properties. * * @private * * @param node Node to propagate down. * * @returns The node where propagation stopped. <br/> * Might return the same `node` from argument if no propagation occurred. */ private propagateDown; private swap; private pushNodeIntoInternalCollection; private leftChild; private rightSibling; private parent; private static isNotRoot; private static detachMetadata; } export { Heap, HeapNode, HEAP_NODE_IDX_SYM };