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).
Type Parameters
Section titled “Type Parameters”T extends DefinedValue
The type of elements in the deque.
Implements
Section titled “Implements”IDeque<T>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Deque<
T>(iterable?,options?):Deque<T>
Defined in: packages/data/src/deque/deque.ts:27
Parameters
Section titled “Parameters”iterable?
Section titled “iterable?”Iterable<T, any, any>
options?
Section titled “options?”DequeOptions<T>
Returns
Section titled “Returns”Deque<T>
Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<T>
Defined in: packages/data/src/deque/deque.ts:39
Returns
Section titled “Returns”Iterator<T>
Implementation of
Section titled “Implementation of”back()
Section titled “back()”back():
T|undefined
Defined in: packages/data/src/deque/deque.ts:79
Returns the item at the back of the deque without removing it.
Returns
Section titled “Returns”T | undefined
The item at the back of the deque, or undefined if the deque is
empty.
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
void
Defined in: packages/data/src/deque/deque.ts:43
Removes all elements from the collection.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”count()
Section titled “count()”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.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”front()
Section titled “front()”front():
T|undefined
Defined in: packages/data/src/deque/deque.ts:75
Returns the item at the front of the deque without removing it.
Returns
Section titled “Returns”T | undefined
The item at the front of the deque, or undefined if the deque is
empty.
Implementation of
Section titled “Implementation of”pop():
T|undefined
Defined in: packages/data/src/deque/deque.ts:71
Removes and returns the item at the back of the deque.
Returns
Section titled “Returns”T | undefined
The item at the back of the deque, or undefined if the deque is
empty.
Implementation of
Section titled “Implementation of”push()
Section titled “push()”push(
item):void
Defined in: packages/data/src/deque/deque.ts:59
Adds an item to the back of the deque.
Parameters
Section titled “Parameters”T
The item to add to the back of the deque.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”pushAll()
Section titled “pushAll()”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.
Parameters
Section titled “Parameters”readonly T[]
The items to add to the back of the deque.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”shift()
Section titled “shift()”shift():
T|undefined
Defined in: packages/data/src/deque/deque.ts:67
Removes and returns the item at the front of the deque.
Returns
Section titled “Returns”T | undefined
The item at the front of the deque, or undefined if the deque is
empty.
Implementation of
Section titled “Implementation of”unshift()
Section titled “unshift()”unshift(
item):void
Defined in: packages/data/src/deque/deque.ts:51
Adds an item to the front of the deque.
Parameters
Section titled “Parameters”T
The item to add to the front of the deque.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”unshiftAll()
Section titled “unshiftAll()”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.
Parameters
Section titled “Parameters”readonly T[]
The items to add to the front of the deque.
Returns
Section titled “Returns”void