Logos DX
    Preparing search index...

    A pure data structure that maintains a set of ordered items by numeric priority. Lower priority numbers dequeue first. Ties are broken by insertion order.

    Time Complexity:

    • Enqueue: O(log n)
    • Dequeue: O(log n)
    • Peek: O(1)

    Space Complexity: O(n) where n is the number of items in the queue

    Type Parameters

    • T
    Index

    Constructors

    Methods

    • Returns an iterator over the queue.

      Returns IterableIterator<T>

    • Clears all items and resets the insertion counter.

      Returns void

    • Find an item in the queue by predicate.

      Parameters

      • predicate: (value: T) => boolean

      Returns T | null

    • Heapify the queue.

      Time Complexity: O(n) Space Complexity: O(n)

      Parameters

      Returns void

    • Returns true if the queue is empty.

      Returns boolean

    • Returns the next item to be dequeued without removing it.

      Returns T | null

    • Returns the next item to be dequeued without removing it.

      Parameters

      • Optionalcount: number

      Returns T[]

    • Removes and returns the highest-priority item. Returns null if the queue is empty.

      Time Complexity: O(log n) Space Complexity: O(1)

      Returns T | null

    • Removes and returns many items from the queue. Returns an empty array if the queue is empty.

      Parameters

      • Optionalcount: number

      Returns T[]

    • Adds a new item into the queue.

      Parameters

      • value: T

        The payload associated with the item

      • Optionalpriority: number

        Numeric priority (lower = higher priority)

        Time Complexity: O(log n) Space Complexity: O(1)

      Returns void

    • Returns the number of items in the queue.

      Returns number

    • Returns a sorted array of the queue.

      Returns T[]