Typed API (TypeDoc) / Queue
Class: Queue<E>
Defined in: queue.ts:59
Example
const queue = new Queue<string>()
queue.enqueue('task')
queue.dequeue()Type Parameters
E
E
Value type.
Implements
IQueue<E>
Constructors
Constructor
new Queue<
E>(elements?,comparator?):Queue<E>
Defined in: queue.ts:75
Parameters
elements?
Iterable<E, any, any>
comparator?
Comparator<E>
Returns
Queue<E>
Properties
comparator
comparator:
Comparator<E>
Defined in: queue.ts:73
Comparator used for equality/sort checks.
Implementation of
size
size:
number=0
Defined in: queue.ts:69
Current element count.
Implementation of
Methods
[iterator]()
[iterator]():
Iterator<E>
Defined in: queue.ts:196
Iterates through the LinkedQueue.
Returns
Iterator<E>
Iterator for the LinkedQueue
Remarks
Complexity: O(n)
Implementation of
IQueue.[iterator]
add()
add(
e):void
Defined in: queue.ts:140
Append an element.
Parameters
e
E
Returns
void
Remarks
Complexity: Amortized O(1) unless stated otherwise.
Implementation of
addAll()
addAll(
collection):void
Defined in: queue.ts:147
Append every element from another collection.
Parameters
collection
ICollection<E>
Returns
void
Remarks
Complexity: O(n + m) where m is collection.size.
Implementation of
clear()
clear():
void
Defined in: queue.ts:103
Remove all entries.
Returns
void
Remarks
Complexity: O(n)
Implementation of
contains()
contains(
element):boolean
Defined in: queue.ts:176
Checks if an element is contained in the Queue. For this function to work, a comparator must be set! O(size) amortized
Parameters
element
E
Returns
boolean
Implementation of
dequeue()
dequeue():
E
Defined in: queue.ts:112
Remove and return the head element.
Returns
E
Dequeued value.
Remarks
Complexity: O(1) amortized
Implementation of
enqueue()
enqueue(
e):void
Defined in: queue.ts:131
Append an element to the tail.
Parameters
e
E
Value to enqueue.
Returns
void
Remarks
Complexity: O(1) amortized
Implementation of
head()
head():
E
Defined in: queue.ts:163
Peek the head without removal.
Returns
E
Head value.
Implementation of
isEmpty()
isEmpty():
boolean
Defined in: queue.ts:156
Check for emptiness.
Returns
boolean
true when size === 0.
Implementation of
remove()
remove(
target,isIndex):number|E
Defined in: queue.ts:242
Remove by value or index.
Parameters
target
Element or index.
number | E
isIndex
boolean = true
When true, treat e as index.
Returns
number | E
Removed element or index of removal.
Remarks
Complexity: O(n) worst case.
Implementation of
reverseIterator()
reverseIterator():
Generator<E>
Defined in: queue.ts:218
Iterates elements from the most recently added to the earliest.
Returns
Generator<E>
Implementation of
sort()
sort(
cmp?):void
Defined in: queue.ts:227
Sort the structure using the provided comparator.
Parameters
cmp?
Comparator<E>
Optional comparator; falls back to the internal one.
Returns
void