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.
Extends
Section titled “Extends”Collection<E>
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”E
Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<E,any,any>
Defined in: site/node_modules/typescript/lib/lib.es2015.iterable.d.ts:47
Returns
Section titled “Returns”Iterator<E, any, any>
Inherited from
Section titled “Inherited from”add(
e):boolean
Defined in: src/interfaces/Collection.ts:54
Ensures this collection contains e.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”boolean
true if the collection changed (a set returns false for a duplicate)
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable
Throws
Section titled “Throws”NullPointerException if e is null and this collection rejects null
Throws
Section titled “Throws”IllegalArgumentException if some property of e prevents adding it (for example a key outside a
sorted view’s range)
Throws
Section titled “Throws”IllegalStateException if a capacity-bounded queue is full
Inherited from
Section titled “Inherited from”addAll()
Section titled “addAll()”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.
Parameters
Section titled “Parameters”Collection<E>
Returns
Section titled “Returns”boolean
true if this collection changed
Throws
Section titled “Throws”NullPointerException if c is null, or contains null and this collection rejects null
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable
Inherited from
Section titled “Inherited from”clear()
Section titled “clear()”clear():
void
Defined in: src/interfaces/Collection.ts:99
Removes all elements.
Returns
Section titled “Returns”void
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable
Inherited from
Section titled “Inherited from”contains()
Section titled “contains()”contains(
o):boolean
Defined in: src/interfaces/Collection.ts:37
Returns true if this collection contains an element equal to o (by Objects.equals).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”NullPointerException if o is null and this collection rejects null (for example the immutable
collections and sorted collections with natural ordering)
Inherited from
Section titled “Inherited from”containsAll()
Section titled “containsAll()”containsAll(
c):boolean
Defined in: src/interfaces/Collection.ts:66
Returns true if this collection contains every element of c.
Parameters
Section titled “Parameters”Collection<unknown>
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”NullPointerException if c is null
Inherited from
Section titled “Inherited from”element()
Section titled “element()”element():
E
Defined in: src/interfaces/Queue.ts:35
Returns the head of this queue without removing it.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if this queue is empty
equals()
Section titled “equals()”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.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”forEach()
Section titled “forEach()”forEach(
action):void
Defined in: src/interfaces/Collection.ts:27
Calls action for each element, in iteration order.
Parameters
Section titled “Parameters”action
Section titled “action”(e) => void
Returns
Section titled “Returns”void
Throws
Section titled “Throws”NullPointerException if action is null
Throws
Section titled “Throws”ConcurrentModificationException if action structurally modifies this collection
Inherited from
Section titled “Inherited from”hashCode()
Section titled “hashCode()”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.
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”isEmpty()
Section titled “isEmpty()”isEmpty():
boolean
Defined in: src/interfaces/Collection.ts:31
Returns true if this collection has no elements.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”iterator()
Section titled “iterator()”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.
Returns
Section titled “Returns”Iterator<E>
Inherited from
Section titled “Inherited from”offer()
Section titled “offer()”offer(
e):boolean
Defined in: src/interfaces/Queue.ts:18
Inserts e into this queue.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”boolean
true if e was added (the library’s queues are unbounded, so always true)
Throws
Section titled “Throws”NullPointerException if e is null and this queue rejects null
Throws
Section titled “Throws”ClassCastException if the queue orders elements and e cannot be compared with them
parallelStream()
Section titled “parallelStream()”parallelStream():
Stream<E>
Defined in: src/interfaces/Collection.ts:118
Returns a stream flagged as parallel; it is evaluated sequentially (JS is single-threaded).
Returns
Section titled “Returns”Stream<E>
Inherited from
Section titled “Inherited from”peek()
Section titled “peek()”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.
Returns
Section titled “Returns”E | null
poll()
Section titled “poll()”poll():
E|null
Defined in: src/interfaces/Queue.ts:30
Removes and returns the head of this queue, or null if it is empty.
Returns
Section titled “Returns”E | null
remove()
Section titled “remove()”Call Signature
Section titled “Call Signature”remove():
E
Defined in: src/interfaces/Queue.ts:23
Removes and returns the head of this queue.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if this queue is empty
Overrides
Section titled “Overrides”Call Signature
Section titled “Call Signature”remove(
o):boolean
Defined in: src/interfaces/Queue.ts:28
Removes one element equal to o, if present.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
true if an element was removed
Overrides
Section titled “Overrides”Collection.remove
removeAll()
Section titled “removeAll()”removeAll(
c):boolean
Defined in: src/interfaces/Collection.ts:80
Removes every element that is also contained in c.
Parameters
Section titled “Parameters”Collection<unknown>
Returns
Section titled “Returns”boolean
true if this collection changed
Throws
Section titled “Throws”NullPointerException if c is null
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable
Inherited from
Section titled “Inherited from”removeIf()
Section titled “removeIf()”removeIf(
filter):boolean
Defined in: src/interfaces/Collection.ts:87
Removes every element for which filter returns true.
Parameters
Section titled “Parameters”filter
Section titled “filter”(e) => boolean
Returns
Section titled “Returns”boolean
true if any element was removed
Throws
Section titled “Throws”NullPointerException if filter is null
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable and an element matches
Inherited from
Section titled “Inherited from”retainAll()
Section titled “retainAll()”retainAll(
c):boolean
Defined in: src/interfaces/Collection.ts:94
Keeps only the elements that are also contained in c, removing all others.
Parameters
Section titled “Parameters”Collection<unknown>
Returns
Section titled “Returns”boolean
true if this collection changed
Throws
Section titled “Throws”NullPointerException if c is null
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable
Inherited from
Section titled “Inherited from”size()
Section titled “size()”size():
number
Defined in: src/interfaces/Collection.ts:29
Returns the number of elements.
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”spliterator()
Section titled “spliterator()”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.
Returns
Section titled “Returns”Spliterator<E>
Inherited from
Section titled “Inherited from”stream()
Section titled “stream()”stream():
Stream<E>
Defined in: src/interfaces/Collection.ts:116
Returns a sequential stream over this collection.
Returns
Section titled “Returns”Stream<E>
Inherited from
Section titled “Inherited from”toArray()
Section titled “toArray()”Call Signature
Section titled “Call Signature”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.
Returns
Section titled “Returns”E[]
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”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).
Type Parameters
Section titled “Type Parameters”A extends WritableArrayLike<E>
Parameters
Section titled “Parameters”generator
Section titled “generator”(length) => A
creates the target array for a given length
Returns
Section titled “Returns”A
Inherited from
Section titled “Inherited from”toString()
Section titled “toString()”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).
Returns
Section titled “Returns”string