import { CompareCallback, DeleteCallback, CloneCallback, ReturnValue, ReturnValueRaw } from "../types"; import { Basic, Options, Container } from "./types"; /** * Initialize array to heap */ export declare function heapify(h: Array, cf?: CompareCallback): Array; /** * Fix re-establishes the heap ordering after the element at index i has changed its value. * @throws TypeError * @throws RangeError */ export declare function fix(h: Array, i: number, cf?: CompareCallback): void; /** * Pop removes and returns the minimum element (according to cf or <) from the heap. * */ export declare function pop(h: Array, cf?: CompareCallback, rf?: DeleteCallback): ReturnValue; export declare function popRaw(h: Array, cf?: CompareCallback, rf?: DeleteCallback): ReturnValueRaw; /** * Push pushes the element x onto the heap. */ export declare function push(h: Array, val: T, cf?: CompareCallback): void; /** * Remove removes and returns the element at index i from the heap. * * @throws TypeError * @throws RangeError */ export declare function remove(h: Array, i: number, cf?: CompareCallback, rf?: DeleteCallback): T; export declare class Heap extends Basic implements Container { /** * Initialize array to heap */ heapify(): void; /** * Fix re-establishes the heap ordering after the element at index i has changed its value. */ fix(i: number): void; /** * array heap */ private readonly h_; /** * Returns an array of underlying storage */ get heap(): Array; /** * returns the length of the heap * @override */ get length(): number; /** * returns the capacity of the heap * @override */ get capacity(): number; /** * get heap array element * @throws TypeError * @throws RangeError */ get(i: number): T; /** * set heap array element * @throws TypeError * @throws RangeError */ set(i: number, val: T): void; constructor(opts?: Options, heap?: Array); /** * Push pushes the element vals onto the heap. */ push(...vals: Array): void; /** * Pop removes and returns the minimum element (according opts.compare cf or <) from the heap. */ pop(): ReturnValue; /** * Pop removes and returns the minimum element (according opts.compare cf or <) from the heap. */ popRaw(): ReturnValueRaw; /** * Remove removes and returns the element at index i from the heap. * * @throws TypeError * @throws RangeError */ remove(i: number): T; /** * Empty the data in the container * * @param callback Call callback on the removed element * @override */ clear(callback?: DeleteCallback): void; /** * return js iterator * @param reverse If true, returns an iterator to traverse in reverse * @override */ iterator(reverse?: boolean): Iterator; /** * Create a full copy of the container * @param callback How to create a duplicate copy of an element */ clone(callback?: CloneCallback): Heap; /** * inserts a copy of another container of heap. */ pushList(vals: Iterable, callback?: CloneCallback): void; }