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

    Class BinaryHeap<T>

    A binary heap implementation.

    Type Parameters

    • T

      The type of elements in the heap.

    Hierarchy

    • NativeListCollection<T>
      • BinaryHeap

    Implements

    Index

    Constructors

    Properties

    capacity: number = Infinity

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

    data: NativeArray<T>
    isItemOrdered: Predicate<[T, T]>

    Methods

    • Concatenates the given items to the end of the collection and returns an iterator over the merged items.

      This method does not mutate the original collection.

      Parameters

      • ...items: T[]

        The items to merge.

      Returns IterableIterator<T>

      An iterator of the merged items.

    • Removes all the items matching the given predicate from the collection.

      Parameters

      • condition: Predicate<[T]>

        A predicate function to identify the items to remove.

      Returns IterableIterator<T>

      An iterable of the removed items.

    • Removes the first occurrence of the item matching the given predicate from the collection.

      Parameters

      • condition: Predicate<[T]>

        A predicate function to identify the item to remove.

      Returns boolean

      true if the item was found and removed, false otherwise.

    • Replaces all the item matching the given predicate in the collection with a new item.

      Parameters

      • condition: Predicate<[T]>

        A predicate function to identify the items to replace.

      • newItem: Callable<[T], T>

        A function that takes the old item and returns the new item to insert.

      Returns IterableIterator<T>

      An iterable of the replaced items.

    • Replaces the first occurence of the item matching the given predicate in the collection with a new item.

      Parameters

      • condition: Predicate<[T]>

        A predicate function to identify the item to replace.

      • newItem: T

        The new item to insert.

      Returns boolean

      true if the item was found and replaced, false otherwise.

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

      Parameters

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

        Optional abort signal to cancel the operation.

      Returns Promise<void>

      IHeap.insert