Skip to content
Buy me a coffee

Queue

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

A collection that holds elements for processing, with a head. Each operation comes in two forms: one throws when the queue is empty (remove(), element()), the other returns null (poll(), peek()). ArrayDeque and PriorityQueue reject null elements (NullPointerException), so there a null result always means “empty”; LinkedList accepts null, which makes poll()/peek() ambiguous. Queues use identity equals/hashCode, except those that are also a List.

E

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

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

Iterator<E, any, any>

Collection.[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

Collection.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

Collection.addAll


clear(): void

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

Removes all elements.

void

UnsupportedOperationException if this collection is unmodifiable

Collection.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)

Collection.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

Collection.containsAll


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


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

Collection.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

Collection.forEach


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

Collection.hashCode


isEmpty(): boolean

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

Returns true if this collection has no elements.

boolean

Collection.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>

Collection.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


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>

Collection.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


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


remove(): E

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

Removes and returns the head of this queue.

E

NoSuchElementException if this queue is empty

Collection.remove

remove(o): boolean

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

Removes one element equal to o, if present.

unknown

boolean

true if an element was removed

Collection.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

Collection.removeAll


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

Collection.removeIf


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

Collection.retainAll


size(): number

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

Returns the number of elements.

number

Collection.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>

Collection.spliterator


stream(): Stream<E>

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

Returns a sequential stream over this collection.

Stream<E>

Collection.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[]

Collection.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

Collection.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

Collection.toString