Skip to content
Buy me a coffee

Deque

Defined in: src/interfaces/Queue.ts:45

A double-ended queue: elements can be inserted, inspected and removed at both ends, so it serves as a FIFO queue (offer/poll work at the tail/head) or a LIFO stack (push/pop work at the head). Methods returning null mean “empty”.

E

[iterator](): Iterator<E, any, any>

Defined in: site/node_modules/typescript/lib/lib.es2015.iterable.d.ts:47

Iterator<E, any, any>

Queue.[iterator]


add(e): boolean

Defined in: src/interfaces/Collection.ts:54

Ensures this collection contains e.

E

boolean

true if the collection changed (a set returns false for a duplicate)

UnsupportedOperationException if this collection is unmodifiable

NullPointerException if e is null and this collection rejects null

IllegalArgumentException if some property of e prevents adding it (for example a key outside a sorted view’s range)

IllegalStateException if a capacity-bounded queue is full

Queue.add


addAll(c): boolean

Defined in: src/interfaces/Collection.ts:73

Adds every element of c, in c’s iteration order. c is copied first, so addAll(this) terminates.

Collection<E>

boolean

true if this collection changed

NullPointerException if c is null, or contains null and this collection rejects null

UnsupportedOperationException if this collection is unmodifiable

Queue.addAll


addFirst(e): void

Defined in: src/interfaces/Collection.ts:133

Adds e as the first element (for a set that already holds it, moves it to the front).

E

void

UnsupportedOperationException if this collection is unmodifiable or sorted

NullPointerException if e is null and this collection rejects null

SequencedCollection.addFirst


addLast(e): void

Defined in: src/interfaces/Collection.ts:139

Adds e as the last element (for a set that already holds it, moves it to the end).

E

void

UnsupportedOperationException if this collection is unmodifiable or sorted

NullPointerException if e is null and this collection rejects null

SequencedCollection.addLast


clear(): void

Defined in: src/interfaces/Collection.ts:99

Removes all elements.

void

UnsupportedOperationException if this collection is unmodifiable

Queue.clear


contains(o): boolean

Defined in: src/interfaces/Collection.ts:37

Returns true if this collection contains an element equal to o (by Objects.equals).

unknown

boolean

NullPointerException if o is null and this collection rejects null (for example the immutable collections and sorted collections with natural ordering)

Queue.contains


containsAll(c): boolean

Defined in: src/interfaces/Collection.ts:66

Returns true if this collection contains every element of c.

Collection<unknown>

boolean

NullPointerException if c is null

Queue.containsAll


descendingIterator(): Iterator<E>

Defined in: src/interfaces/Queue.ts:98

Returns a fail-fast iterator over the elements from last to first.

Iterator<E>


element(): E

Defined in: src/interfaces/Queue.ts:35

Returns the head of this queue without removing it.

E

NoSuchElementException if this queue is empty

Queue.element


equals(o): boolean

Defined in: src/interfaces/Collection.ts:105

Compares this collection with o for equality. A List equals any other List with the same elements in the same order; a Set equals any other Set with the same elements; other collections (queues, deques, values() views) use identity.

unknown

boolean

Queue.equals


forEach(action): void

Defined in: src/interfaces/Collection.ts:27

Calls action for each element, in iteration order.

(e) => void

void

NullPointerException if action is null

ConcurrentModificationException if action structurally modifies this collection

Queue.forEach


getFirst(): E

Defined in: src/interfaces/Collection.ts:144

Returns the first element.

E

NoSuchElementException if this collection is empty

SequencedCollection.getFirst


getLast(): E

Defined in: src/interfaces/Collection.ts:149

Returns the last element.

E

NoSuchElementException if this collection is empty

SequencedCollection.getLast


hashCode(): number

Defined in: src/interfaces/Collection.ts:110

Returns a hash code consistent with equals. A list hashes as h = 31 * h + hash(e) starting from 1, a set as the sum of its element hashes (both in 32-bit arithmetic); other collections use an identity hash.

number

Queue.hashCode


isEmpty(): boolean

Defined in: src/interfaces/Collection.ts:31

Returns true if this collection has no elements.

boolean

Queue.isEmpty


iterator(): Iterator<E>

Defined in: src/interfaces/Collection.ts:21

Returns a fail-fast iterator over the elements, in this collection’s encounter order (if it has one). Its remove() throws UnsupportedOperationException on an unmodifiable collection.

Iterator<E>

Queue.iterator


offer(e): boolean

Defined in: src/interfaces/Queue.ts:18

Inserts e into this queue.

E

boolean

true if e was added (the library’s queues are unbounded, so always true)

NullPointerException if e is null and this queue rejects null

ClassCastException if the queue orders elements and e cannot be compared with them

Queue.offer


offerFirst(e): boolean

Defined in: src/interfaces/Queue.ts:61

Inserts e at the front.

E

boolean

true if e was added

NullPointerException if e is null and this deque rejects null


offerLast(e): boolean

Defined in: src/interfaces/Queue.ts:67

Inserts e at the end.

E

boolean

true if e was added

NullPointerException if e is null and this deque rejects null


parallelStream(): Stream<E>

Defined in: src/interfaces/Collection.ts:118

Returns a stream flagged as parallel; it is evaluated sequentially (JS is single-threaded).

Stream<E>

Queue.parallelStream


peek(): E | null

Defined in: src/interfaces/Queue.ts:37

Returns the head of this queue without removing it, or null if it is empty.

E | null

Queue.peek


peekFirst(): E | null

Defined in: src/interfaces/Queue.ts:73

Returns the first element without removing it, or null if this deque is empty.

E | null


peekLast(): E | null

Defined in: src/interfaces/Queue.ts:75

Returns the last element without removing it, or null if this deque is empty.

E | null


poll(): E | null

Defined in: src/interfaces/Queue.ts:30

Removes and returns the head of this queue, or null if it is empty.

E | null

Queue.poll


pollFirst(): E | null

Defined in: src/interfaces/Queue.ts:69

Removes and returns the first element, or null if this deque is empty.

E | null


pollLast(): E | null

Defined in: src/interfaces/Queue.ts:71

Removes and returns the last element, or null if this deque is empty.

E | null


pop(): E

Defined in: src/interfaces/Queue.ts:96

Pops the top of the stack this deque represents, that is, removes and returns the first element; same as removeFirst().

E

NoSuchElementException if this deque is empty


push(e): void

Defined in: src/interfaces/Queue.ts:90

Pushes e onto the stack this deque represents, that is, inserts it at the front; same as addFirst(e).

E

void

NullPointerException if e is null and this deque rejects null


remove(): E

Defined in: src/interfaces/Queue.ts:50

Removes and returns the first element; same as removeFirst().

E

NoSuchElementException if this deque is empty

Queue.remove

remove(o): boolean

Defined in: src/interfaces/Queue.ts:55

Removes the first element equal to o, if present; same as removeFirstOccurrence(o).

unknown

boolean

true if an element was removed

Queue.remove


removeAll(c): boolean

Defined in: src/interfaces/Collection.ts:80

Removes every element that is also contained in c.

Collection<unknown>

boolean

true if this collection changed

NullPointerException if c is null

UnsupportedOperationException if this collection is unmodifiable

Queue.removeAll


removeFirst(): E

Defined in: src/interfaces/Collection.ts:155

Removes and returns the first element.

E

NoSuchElementException if this collection is empty

UnsupportedOperationException if this collection is unmodifiable

SequencedCollection.removeFirst


removeFirstOccurrence(o): boolean

Defined in: src/interfaces/Queue.ts:80

Removes the first element (from head to tail) equal to o.

unknown

boolean

true if an element was removed


removeIf(filter): boolean

Defined in: src/interfaces/Collection.ts:87

Removes every element for which filter returns true.

(e) => boolean

boolean

true if any element was removed

NullPointerException if filter is null

UnsupportedOperationException if this collection is unmodifiable and an element matches

Queue.removeIf


removeLast(): E

Defined in: src/interfaces/Collection.ts:161

Removes and returns the last element.

E

NoSuchElementException if this collection is empty

UnsupportedOperationException if this collection is unmodifiable

SequencedCollection.removeLast


removeLastOccurrence(o): boolean

Defined in: src/interfaces/Queue.ts:85

Removes the last element (the first found from tail to head) equal to o.

unknown

boolean

true if an element was removed


retainAll(c): boolean

Defined in: src/interfaces/Collection.ts:94

Keeps only the elements that are also contained in c, removing all others.

Collection<unknown>

boolean

true if this collection changed

NullPointerException if c is null

UnsupportedOperationException if this collection is unmodifiable

Queue.retainAll


reversed(): Deque<E>

Defined in: src/interfaces/Queue.ts:100

Returns a live reverse-ordered view: changes through either side are visible in the other.

Deque<E>

SequencedCollection.reversed


size(): number

Defined in: src/interfaces/Collection.ts:29

Returns the number of elements.

number

Queue.size


spliterator(): Spliterator<E>

Defined in: src/interfaces/Collection.ts:114

Returns a spliterator over the elements, used to build streams. Fail-fast like the iterator.

Spliterator<E>

Queue.spliterator


stream(): Stream<E>

Defined in: src/interfaces/Collection.ts:116

Returns a sequential stream over this collection.

Stream<E>

Queue.stream


toArray(): E[]

Defined in: src/interfaces/Collection.ts:39

Returns a new array with all elements, in iteration order. Changing the array does not affect this collection.

E[]

Queue.toArray

toArray<A>(generator): A

Defined in: src/interfaces/Collection.ts:44

Fills an array created by generator(size()), in iteration order, and returns it; e.g. n => new Float64Array(n).

A extends WritableArrayLike<E>

(length) => A

creates the target array for a given length

A

Queue.toArray


toString(): string

Defined in: src/interfaces/Collection.ts:112

Returns the elements in iteration order as [a, b, c]; an element that is this collection prints as (this Collection).

string

Queue.toString