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

    Interface IPriorityQueue<T, P>

    Interface representing a priority queue data type.

    A priority queue is a collection where each item has a priority associated with it. Items with higher priority are served before items with lower priority.

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

    Type Parameters

    • T = unknown

      The type of elements in the priority queue.

    • P = number

      The type of priority values.

    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.

    Predicate function which determine if one priority is higher than another.

    Methods

    • Returns AsyncIterator<[T, P], any, any>

    • Returns Iterator<Promisable<[T, P]>, any, any>

    • Inserts one or more items with their associated priorities into the priority queue.

      Parameters

      • priority: P

        The priority of the items to insert.

      • ...items: T[]

        The items to insert.

      Returns Promisable<void>

      If the operation would exceed the deque's capacity.

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

      Parameters

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

        Optional abort signal to cancel the operation.

      Returns PromiseLike<void>

      IPriorityQueue.insert