PriorityQueue
Defined in: packages/data/src/priority-queue/priority-queue.ts:21
An unbounded priority queue.
For a capacity, use BoundedPriorityQueue (throws when full) or
BlockingPriorityQueue (waits).
Type Parameters
Section titled “Type Parameters”T extends DefinedValue
The type of elements in the priority queue.
P = number
The type of priority associated with each element.
Implements
Section titled “Implements”IPriorityQueue<T,P>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PriorityQueue<
T,P>(precedes?,iterable?,options?):PriorityQueue<T,P>
Defined in: packages/data/src/priority-queue/priority-queue.ts:28
Parameters
Section titled “Parameters”precedes?
Section titled “precedes?”OrderPredicate<P> = ...
iterable?
Section titled “iterable?”Iterable<[T, P], any, any>
options?
Section titled “options?”PriorityQueueOptions<T, P>
Returns
Section titled “Returns”PriorityQueue<T, P>
Properties
Section titled “Properties”precedes
Section titled “precedes”
readonlyprecedes:OrderPredicate<P>
Defined in: packages/data/src/priority-queue/priority-queue.ts:29
Strict weak ordering over priorities: precedes(a, b) means a outranks
b.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<T>
Defined in: packages/data/src/priority-queue/priority-queue.ts:45
Returns
Section titled “Returns”Iterator<T>
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
void
Defined in: packages/data/src/priority-queue/priority-queue.ts:51
Removes all elements from the collection.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”count()
Section titled “count()”count():
number
Defined in: packages/data/src/priority-queue/priority-queue.ts:55
The number of elements in the collection.
A method, not a getter: its async counterpart needs a round trip to the backing store, and a member must have the same shape in both.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”entries()
Section titled “entries()”entries():
IterableIterator<PriorityEntry<T,P>>
Defined in: packages/data/src/priority-queue/priority-queue.ts:164
Drains a copy of the heap in priority order, leaving this queue untouched — the storage’s own iteration order is heap order, not priority order.
Returns
Section titled “Returns”IterableIterator<PriorityEntry<T, P>>
Implementation of
Section titled “Implementation of”extract()
Section titled “extract()”extract():
T|undefined
Defined in: packages/data/src/priority-queue/priority-queue.ts:71
Removes and returns the item with the highest priority from the priority queue.
Returns
Section titled “Returns”T | undefined
The item with the highest priority, or undefined if the queue is
empty.
Implementation of
Section titled “Implementation of”insert()
Section titled “insert()”insert(
priority,value):void
Defined in: packages/data/src/priority-queue/priority-queue.ts:59
Inserts an item with its associated priority into the priority queue.
Parameters
Section titled “Parameters”priority
Section titled “priority”P
The priority of the item to insert.
T
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”insertAll()
Section titled “insertAll()”insertAll(
priority,items):void
Defined in: packages/data/src/priority-queue/priority-queue.ts:64
Inserts every item at the same priority into the priority queue.
Parameters
Section titled “Parameters”priority
Section titled “priority”P
The priority shared by all the items to insert.
readonly T[]
The items to insert.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”peek()
Section titled “peek()”peek():
T|undefined
Defined in: packages/data/src/priority-queue/priority-queue.ts:89
Returns the item with the highest priority without removing it from the queue.
Returns
Section titled “Returns”T | undefined
The item with the highest priority, or undefined if the queue is
empty.
Implementation of
Section titled “Implementation of”remove()
Section titled “remove()”remove(
condition):boolean
Defined in: packages/data/src/priority-queue/priority-queue.ts:132
Removes the first entry matching condition, restoring the heap property
afterward.
Not part of IPriorityQueue — reaching into the middle of a priority queue
by value is a real, occasionally needed capability (e.g. unregistering a
previously inserted handler), but not one every consumer needs, matching
the extra removeFirst-style surface the list classes carry beyond their
own slim interfaces.
Parameters
Section titled “Parameters”condition
Section titled “condition”Predicate<[T, P]>
A predicate over an entry’s value and priority.
Returns
Section titled “Returns”boolean
true if a matching entry was found and removed.
setPriority()
Section titled “setPriority()”setPriority(
item,priority):boolean
Defined in: packages/data/src/priority-queue/priority-queue.ts:93
Updates the priority of an existing item in the priority queue.
Parameters
Section titled “Parameters”T
The item whose priority is to be updated.
priority
Section titled “priority”P
The new priority of the item.
Returns
Section titled “Returns”boolean
true if the item was found and its priority updated, false
otherwise.