BoundedPriorityQueue
Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:23
A priority queue that holds at most capacity items and throws once full.
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>IBounded
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BoundedPriorityQueue<
T,P>(precedes?,iterable,options):BoundedPriorityQueue<T,P>
Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:29
Parameters
Section titled “Parameters”precedes?
Section titled “precedes?”OrderPredicate<P> = ...
iterable
Section titled “iterable”Iterable<[T, P], any, any> | undefined
options
Section titled “options”BoundedPriorityQueueOptions<T, P>
Returns
Section titled “Returns”BoundedPriorityQueue<T, P>
Properties
Section titled “Properties”capacity
Section titled “capacity”
readonlycapacity:number
Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:27
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”precedes
Section titled “precedes”
readonlyprecedes:OrderPredicate<P>
Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:30
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/bounded-priority-queue.ts:42
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/bounded-priority-queue.ts:46
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/bounded-priority-queue.ts:50
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/bounded-priority-queue.ts:99
Every entry, in priority order (highest first).
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/bounded-priority-queue.ts:82
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,item):void
Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:61
Same as IPriorityQueue.insert, but throws once the queue is full.
Parameters
Section titled “Parameters”priority
Section titled “priority”P
T
Returns
Section titled “Returns”void
Throws
Section titled “Throws”If the operation would exceed the queue’s capacity.
IPriorityQueue.insert
Implementation of
Section titled “Implementation of”insertAll()
Section titled “insertAll()”insertAll(
priority,items):void
Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:76
Same as IPriorityQueue.insertAll, but throws once the queue is full.
Nothing is inserted when it throws — the check is made against the whole
batch.
Parameters
Section titled “Parameters”priority
Section titled “priority”P
readonly T[]
Returns
Section titled “Returns”void
Throws
Section titled “Throws”If the operation would exceed the queue’s capacity.
IPriorityQueue.insertAll
Implementation of
Section titled “Implementation of”peek()
Section titled “peek()”peek():
T|undefined
Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:86
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/bounded-priority-queue.ts:95
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/bounded-priority-queue.ts:90
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.