@ac-essentials/misc-util
    Preparing search index...

    Interface IHeap<T>

    Interface representing a heap data type.

    interface IHeap<T = unknown> {
        capacity: number;
        "[asyncIterator]"(): AsyncIterator<T, any, any>;
        "[iterator]"(): Iterator<Promisable<T>, any, any>;
        clear(): Promisable<void>;
        concat(...items: T[]): MaybeAsyncIterableIterator<T>;
        count(): Promisable<number>;
        extract(): Promisable<undefined | T>;
        extractAndInsert(item: T): Promisable<undefined | T>;
        insert(...items: T[]): Promisable<void>;
        insertAndExtract(item: T): Promisable<undefined | T>;
        remove(
            condition: Predicate<[T]>,
        ): Promisable<MaybeAsyncIterableIterator<T>>;
        removeFirst(condition: Predicate<[T]>): Promisable<boolean>;
        replace(
            condition: Predicate<[T]>,
            newItemFactory: Callable<[T], T>,
        ): Promisable<MaybeAsyncIterableIterator<T>>;
        replaceFirst(condition: Predicate<[T]>, newItem: T): Promisable<boolean>;
        root(): Promisable<undefined | T>;
        waitInsert(
            items: Iterable<T>,
            signal?: null | AbortSignal,
        ): PromiseLike<void>;
    }

    Type Parameters

    • T = unknown

      The type of elements in the heap.

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    capacity: number

    The maximum number of elements the collection can hold. If the collection is unbounded, this will be Infinity.

    Methods

    • Returns AsyncIterator<T, any, any>

    • Returns Iterator<Promisable<T>, any, any>

    • Inserts an item into the heap and then extracts and returns the root item in one operation.

      Parameters

      • item: T

        The item to insert and extract.

      Returns Promisable<undefined | T>

    • Same as insert, but waits for capacity if the operation would exceed it.

      Parameters

      • items: Iterable<T>
      • Optionalsignal: null | AbortSignal

        Optional abort signal to cancel the operation.

      Returns PromiseLike<void>

      IHeap.insert