BlockingPriorityQueue
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:26
A priority queue that holds at most capacity items, and whose waitInsert
suspends until room frees up instead of throwing.
insert still throws — this type adds a way to wait, it does not change the
way to fail.
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”IWaitablePriorityQueue<T,P>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BlockingPriorityQueue<
T,P>(precedes?,iterable,options):BlockingPriorityQueue<T,P>
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:34
Parameters
Section titled “Parameters”precedes?
Section titled “precedes?”OrderPredicate<P> = ...
iterable
Section titled “iterable”Iterable<[T, P], any, any> | undefined
options
Section titled “options”BlockingPriorityQueueOptions<T, P>
Returns
Section titled “Returns”BlockingPriorityQueue<T, P>
Properties
Section titled “Properties”capacity
Section titled “capacity”
readonlycapacity:number
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:32
The maximum number of elements the collection can hold.
Note: Infinity is not a legal value here — an unbounded type omits this
mixin.
Implementation of
Section titled “Implementation of”IWaitablePriorityQueue.capacity
precedes
Section titled “precedes”
readonlyprecedes:OrderPredicate<P>
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:35
Strict weak ordering over priorities: precedes(a, b) means a outranks
b.
Implementation of
Section titled “Implementation of”IWaitablePriorityQueue.precedes
Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<T>
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:51
Returns
Section titled “Returns”Iterator<T>
Implementation of
Section titled “Implementation of”IWaitablePriorityQueue.[iterator]
clear()
Section titled “clear()”clear():
void
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:55
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/blocking-priority-queue.ts:62
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/blocking-priority-queue.ts:133
Every entry, in priority order (highest first).
Returns
Section titled “Returns”IterableIterator<PriorityEntry<T, P>>
Implementation of
Section titled “Implementation of”IWaitablePriorityQueue.entries
extract()
Section titled “extract()”extract():
T|undefined
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:104
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”IWaitablePriorityQueue.extract
insert()
Section titled “insert()”insert(
priority,item):void
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:66
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
The item to insert.
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/blocking-priority-queue.ts:71
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”IWaitablePriorityQueue.insertAll
peek()
Section titled “peek()”peek():
T|undefined
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:114
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/blocking-priority-queue.ts:123
Parameters
Section titled “Parameters”condition
Section titled “condition”Predicate<[T, P]>
Returns
Section titled “Returns”boolean
PriorityQueue.remove
setPriority()
Section titled “setPriority()”setPriority(
item,priority):boolean
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:118
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.
Implementation of
Section titled “Implementation of”IWaitablePriorityQueue.setPriority
waitInsert()
Section titled “waitInsert()”waitInsert(
priority,item,signal?):Promise<void>
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:80
Same as insert, but waits for capacity if the operation would exceed it.
Parameters
Section titled “Parameters”priority
Section titled “priority”P
T
signal?
Section titled “signal?”AbortSignal | null
Optional abort signal to cancel the operation.
Returns
Section titled “Returns”Promise<void>
IPriorityQueue.insert
Implementation of
Section titled “Implementation of”IWaitablePriorityQueue.waitInsert
waitInsertAll()
Section titled “waitInsertAll()”waitInsertAll(
priority,items,signal?):Promise<void>
Defined in: packages/data/src/priority-queue/blocking-priority-queue.ts:89
Same as insertAll, but waits for capacity if the operation would exceed
it. The whole batch lands at once, never interleaved with another
waiter’s.
Parameters
Section titled “Parameters”priority
Section titled “priority”P
Iterable<T>
signal?
Section titled “signal?”AbortSignal | null
Optional abort signal to cancel the operation.
Returns
Section titled “Returns”Promise<void>
IPriorityQueue.insertAll