R
C

Queue

v0.0.8tested

Represents a queue data structure (FIFO) backed by a Deque

Signature

ts
class Queue<T> implements QueueLike<T>

Type Parameters

T

Properties

PropertyTypeDescription
lengthreadonlynumberGets the number of elements in the queue
isEmptyreadonlybooleanChecks if the queue is empty
isFullreadonlybooleanChecks if the queue is full

Methods

enqueue

Adds an element to the back of the queue

ts
enqueue(element: T)
ParameterTypeDescription
elementTThe element to enqueue
Returnsthis
dequeue

Removes and returns the front element of the queue

ts
dequeue()
ReturnsT | undefinedThe front element, or undefined if the queue is empty
peek

Returns the front element without removing it

ts
peek()
ReturnsT | undefinedThe front element, or undefined if the queue is empty
clear

Clears the queue

ts
clear()
Returnsthis
toArray

Converts the queue to an array in FIFO order

ts
toArray()
ReturnsT[]
toString

Returns a string representation of the queue

ts
toString()
Returnsstring
[Symbol.iterator]

Returns an iterator for the queue

ts
[Symbol.iterator]()
ReturnsIterableIterator<T>
[Symbol.asyncIterator]

Returns an async iterator for the queue

ts
async* [Symbol.asyncIterator]()
ReturnsAsyncGenerator<Awaited<T>, void, unknown>