R
C

Deque

v0.0.8tested

Represents a double-ended queue backed by a circular buffer

Signature

ts
class Deque<T> implements DequeLike<T>

Type Parameters

T

Properties

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

Methods

pushBack

Adds an element to the back of the deque

ts
pushBack(element: T)
ParameterTypeDescription
elementTThe element to add
Returnsthis
pushFront

Adds an element to the front of the deque

ts
pushFront(element: T)
ParameterTypeDescription
elementTThe element to add
Returnsthis
popBack

Removes and returns the back element of the deque

ts
popBack()
ReturnsT | undefinedThe back element, or undefined if empty
popFront

Removes and returns the front element of the deque

ts
popFront()
ReturnsT | undefinedThe front element, or undefined if empty
peekBack

Returns the back element without removing it

ts
peekBack()
ReturnsT | undefinedThe back element, or undefined if empty
peekFront

Returns the front element without removing it

ts
peekFront()
ReturnsT | undefinedThe front element, or undefined if empty
clear

Clears the deque

ts
clear()
Returnsthis
toArray

Converts the deque to an array from front to back

ts
toArray()
ReturnsT[]
toString

Returns a string representation of the deque

ts
toString()
Returnsstring
[Symbol.iterator]

Returns an iterator for the deque (front to back)

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

Returns an async iterator for the deque (front to back)

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