C
Deque
v0.0.8testedRepresents a double-ended queue backed by a circular buffer
Signature
ts
class Deque<T> implements DequeLike<T>Type Parameters
TProperties
| Property | Type | Description |
|---|---|---|
lengthreadonly | number | Gets the number of elements in the deque |
isEmptyreadonly | boolean | Checks if the deque is empty |
isFullreadonly | boolean | Checks if the deque is full |
Methods
pushBackAdds an element to the back of the deque
ts
pushBack(element: T)| Parameter | Type | Description |
|---|---|---|
element | T | The element to add |
Returns
thispushFrontAdds an element to the front of the deque
ts
pushFront(element: T)| Parameter | Type | Description |
|---|---|---|
element | T | The element to add |
Returns
thispopBackRemoves and returns the back element of the deque
ts
popBack()Returns
T | undefinedThe back element, or undefined if emptypopFrontRemoves and returns the front element of the deque
ts
popFront()Returns
T | undefinedThe front element, or undefined if emptypeekBackReturns the back element without removing it
ts
peekBack()Returns
T | undefinedThe back element, or undefined if emptypeekFrontReturns the front element without removing it
ts
peekFront()Returns
T | undefinedThe front element, or undefined if emptyclearClears the deque
ts
clear()Returns
thistoArrayConverts the deque to an array from front to back
ts
toArray()Returns
T[]toStringReturns a string representation of the deque
ts
toString()Returns
string[Symbol.iterator]Returns an iterator for the deque (front to back)
ts
[Symbol.iterator]()Returns
IterableIterator<T>[Symbol.asyncIterator]Returns an async iterator for the deque (front to back)
ts
async* [Symbol.asyncIterator]()Returns
AsyncGenerator<Awaited<T>, void, unknown>