Skip to content

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.

T extends DefinedValue

The type of elements in the priority queue.

P = number

The type of priority associated with each element.

new BoundedPriorityQueue<T, P>(precedes?, iterable, options): BoundedPriorityQueue<T, P>

Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:29

OrderPredicate<P> = ...

Iterable<[T, P], any, any> | undefined

BoundedPriorityQueueOptions<T, P>

BoundedPriorityQueue<T, P>

readonly capacity: 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.

IBounded.capacity


readonly precedes: 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.

IPriorityQueue.precedes

[iterator](): Iterator<T>

Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:42

Iterator<T>

IPriorityQueue.[iterator]


clear(): void

Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:46

Removes all elements from the collection.

void

IPriorityQueue.clear


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.

number

IPriorityQueue.count


entries(): IterableIterator<PriorityEntry<T, P>>

Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:99

Every entry, in priority order (highest first).

IterableIterator<PriorityEntry<T, P>>

IPriorityQueue.entries


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.

T | undefined

The item with the highest priority, or undefined if the queue is empty.

IPriorityQueue.extract


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.

P

T

void

If the operation would exceed the queue’s capacity.

IPriorityQueue.insert

IPriorityQueue.insert


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.

P

readonly T[]

void

If the operation would exceed the queue’s capacity.

IPriorityQueue.insertAll

IPriorityQueue.insertAll


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.

T | undefined

The item with the highest priority, or undefined if the queue is empty.

IPriorityQueue.peek


remove(condition): boolean

Defined in: packages/data/src/priority-queue/bounded-priority-queue.ts:95

Predicate<[T, P]>

boolean

PriorityQueue.remove


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.

T

The item whose priority is to be updated.

P

The new priority of the item.

boolean

true if the item was found and its priority updated, false otherwise.

IPriorityQueue.setPriority