Skip to content

Deque

Defined in: packages/data/src/deque/deque.ts:24

An unbounded double-ended queue.

Backed by RingVector — one flat wrap-around array, so both ends are O(1) with no per-element node allocation. DoublyLinkedList also satisfies DequeStorage and is the right choice when elements must survive being spliced out of the middle; it is not the right default.

For a capacity, use BoundedDeque (throws when full) or BlockingDeque (waits).

T extends DefinedValue

The type of elements in the deque.

new Deque<T>(iterable?, options?): Deque<T>

Defined in: packages/data/src/deque/deque.ts:27

Iterable<T, any, any>

DequeOptions<T>

Deque<T>

[iterator](): Iterator<T>

Defined in: packages/data/src/deque/deque.ts:39

Iterator<T>

IDeque.[iterator]


back(): T | undefined

Defined in: packages/data/src/deque/deque.ts:79

Returns the item at the back of the deque without removing it.

T | undefined

The item at the back of the deque, or undefined if the deque is empty.

IDeque.back


clear(): void

Defined in: packages/data/src/deque/deque.ts:43

Removes all elements from the collection.

void

IDeque.clear


count(): number

Defined in: packages/data/src/deque/deque.ts:47

The number of elements in the collection.

A method, not a getter: its async counterpart needs a round trip to the backing store, and a member must have the same shape in both.

number

IDeque.count


front(): T | undefined

Defined in: packages/data/src/deque/deque.ts:75

Returns the item at the front of the deque without removing it.

T | undefined

The item at the front of the deque, or undefined if the deque is empty.

IDeque.front


pop(): T | undefined

Defined in: packages/data/src/deque/deque.ts:71

Removes and returns the item at the back of the deque.

T | undefined

The item at the back of the deque, or undefined if the deque is empty.

IDeque.pop


push(item): void

Defined in: packages/data/src/deque/deque.ts:59

Adds an item to the back of the deque.

T

The item to add to the back of the deque.

void

IDeque.push


pushAll(items): void

Defined in: packages/data/src/deque/deque.ts:63

Adds every item to the back of the deque.

The items keep their relative order, so the last element of the array becomes the new back — Array.prototype.push semantics.

readonly T[]

The items to add to the back of the deque.

void

IDeque.pushAll


shift(): T | undefined

Defined in: packages/data/src/deque/deque.ts:67

Removes and returns the item at the front of the deque.

T | undefined

The item at the front of the deque, or undefined if the deque is empty.

IDeque.shift


unshift(item): void

Defined in: packages/data/src/deque/deque.ts:51

Adds an item to the front of the deque.

T

The item to add to the front of the deque.

void

IDeque.unshift


unshiftAll(items): void

Defined in: packages/data/src/deque/deque.ts:55

Adds every item to the front of the deque.

The items keep their relative order, so the first element of the array becomes the new front — Array.prototype.unshift semantics.

readonly T[]

The items to add to the front of the deque.

void

IDeque.unshiftAll