dastal - v5.0.0 / Queue
An ordered collection of elements in FIFO (first-in-first-out) order (source).
Typically FIFO refers to the insertion order of elements. However, it can refer to other types of ordering. For example, priority queues order elements over the elements natural ordering (e.g. 2 before 4) or according to a given comparator. LIFO queues (e.g. stacks) order elements in last-in-first-out order.
Regardless, a call to dequeue() should return the first element relative to its order. Every implementation should specify its ordering properties. Otherwise, insertion order should be used.
Name |
---|
T |
-
Collection<T>
↳ Queue
• Readonly
size: number
The number of elements in the collection.
src/collection/collection.ts:5
▸ [iterator](): Iterator
<T, any, undefined>
Iterator
<T, any, undefined>
node_modules/typescript/lib/lib.es2015.iterable.d.ts:51
▸ clear(): void
Removes all elements.
void
▸ dequeue(): undefined
| T
Retrieves and removes the head of this queue
undefined
| T
The value at the head of the queue or undefined
if this queue is empty.
▸ enqueue(element
): number
Inserts the specified value into this queue
Name | Type | Description |
---|---|---|
element |
T |
The element to be inserted |
number
The new size of the queue
▸ peek(): undefined
| T
Retrieves, but does not remove, the head of this queue
undefined
| T
The value at the head of the queue or undefined
if this queue is empty.