Skip to content
Buy me a coffee

AbstractQueue

Defined in: src/abstract/AbstractQueue.ts:16

Skeleton implementation of the Queue interface for queues that reject null elements, since a null from poll()/peek() always means “empty”.

A subclass implements offer, poll, peek, iterator() and size(). It inherits the throwing variants add (IllegalStateException when offer refuses), remove() and element() (NoSuchElementException when empty), plus clear (polls until empty) and addAll. Fail-fast behaviour is whatever the subclass’s iterator provides.

E

new AbstractQueue<E>(): AbstractQueue<E>

AbstractQueue<E>

AbstractCollection.constructor

[INSPECT](): string

Defined in: src/abstract/AbstractCollection.ts:195

Node’s util.inspect hook: console.log prints the toString() form.

string

AbstractCollection.[INSPECT]


[iterator](): IterableIterator<E>

Defined in: src/abstract/AbstractCollection.ts:164

Makes the collection usable with for..of and spread; walks iterator().

IterableIterator<E>

Queue.[iterator]

AbstractCollection.[iterator]


add(e): boolean

Defined in: src/abstract/AbstractQueue.ts:28

Inserts e via offer; returns true.

E

boolean

IllegalStateException if offer returns false (the queue is full)

Queue.add

AbstractCollection.add


addAll(c): boolean

Defined in: src/abstract/AbstractQueue.ts:68

Calls add for each element of c; returns true if the queue changed.

Collection<E>

boolean

NullPointerException if c is null

IllegalArgumentException if c is this queue

IllegalStateException if the queue fills up part-way (earlier elements stay added)

Queue.addAll

AbstractCollection.addAll


clear(): void

Defined in: src/abstract/AbstractQueue.ts:58

Removes every element by calling poll() until it returns null.

void

Queue.clear

AbstractCollection.clear


contains(o): boolean

Defined in: src/abstract/AbstractCollection.ts:34

Returns true if some element equals o (by Objects.equals); a linear scan of iterator().

unknown

boolean

Queue.contains

AbstractCollection.contains


containsAll(c): boolean

Defined in: src/abstract/AbstractCollection.ts:83

Returns true if this collection contains every element of c (calls contains for each).

Collection<unknown>

boolean

NullPointerException if c is null

Queue.containsAll

AbstractCollection.containsAll


element(): E

Defined in: src/abstract/AbstractQueue.ts:51

Returns the head without removing it, via peek.

E

NoSuchElementException if the queue is empty

Queue.element


equals(o): boolean

Defined in: src/abstract/AbstractCollection.ts:185

Identity by default; List/Set/Map subclasses override with value equality.

unknown

boolean

Queue.equals

AbstractCollection.equals


forEach(action): void

Defined in: src/abstract/AbstractCollection.ts:157

Calls action for each element in iteration order.

(e) => void

void

NullPointerException if action is null

Queue.forEach

AbstractCollection.forEach


hashCode(): number

Defined in: src/abstract/AbstractCollection.ts:190

Identity hash by default, consistent with the identity equals.

number

Queue.hashCode

AbstractCollection.hashCode


isEmpty(): boolean

Defined in: src/abstract/AbstractCollection.ts:29

Returns size() === 0.

boolean

Queue.isEmpty

AbstractCollection.isEmpty


abstract iterator(): Iterator<E>

Defined in: src/abstract/AbstractCollection.ts:24

Returns an iterator over the elements. Subclasses implement it; its remove() backs every removal method.

Iterator<E>

Queue.iterator

AbstractCollection.iterator


abstract offer(e): boolean

Defined in: src/abstract/AbstractQueue.ts:18

Inserts e if there is room; returns false when a bounded queue is full. Subclasses implement it and reject null.

E

boolean

Queue.offer


parallelStream(): Stream<E>

Defined in: src/abstract/AbstractCollection.ts:180

Returns a stream over spliterator() flagged as parallel.

Stream<E>

Queue.parallelStream

AbstractCollection.parallelStream


abstract peek(): E | null

Defined in: src/abstract/AbstractQueue.ts:22

Returns the head without removing it, or null when empty. Subclasses implement it.

E | null

Queue.peek


abstract poll(): E | null

Defined in: src/abstract/AbstractQueue.ts:20

Removes and returns the head, or null when empty. Subclasses implement it.

E | null

Queue.poll


remove(): E

Defined in: src/abstract/AbstractQueue.ts:37

Removes and returns the head, via poll.

E

NoSuchElementException if the queue is empty

Queue.remove

AbstractCollection.remove

remove(o): boolean

Defined in: src/abstract/AbstractQueue.ts:39

Removes one element equal to o through the iterator; returns true if one was removed.

unknown

boolean

Queue.remove

AbstractCollection.remove


removeAll(c): boolean

Defined in: src/abstract/AbstractCollection.ts:108

Removes every element that c contains, through the iterator’s remove(); returns true if any was removed.

Collection<unknown>

boolean

NullPointerException if c is null

Queue.removeAll

AbstractCollection.removeAll


removeIf(filter): boolean

Defined in: src/abstract/AbstractCollection.ts:128

Removes every element for which filter returns true, through the iterator’s remove(); returns true if any was removed.

(e) => boolean

boolean

NullPointerException if filter is null

Queue.removeIf

AbstractCollection.removeIf


retainAll(c): boolean

Defined in: src/abstract/AbstractCollection.ts:118

Removes every element that c does not contain, through the iterator’s remove(); returns true if any was removed.

Collection<unknown>

boolean

NullPointerException if c is null

Queue.retainAll

AbstractCollection.retainAll


abstract size(): number

Defined in: src/abstract/AbstractCollection.ts:26

Returns the number of elements. Subclasses implement it.

number

Queue.size

AbstractCollection.size


spliterator(): Spliterator<E>

Defined in: src/abstract/AbstractCollection.ts:170

Late-binding SIZED|SUBSIZED spliterator over iterator(), splitting in batches; collections override with faster ones.

Spliterator<E>

Queue.spliterator

AbstractCollection.spliterator


stream(): Stream<E>

Defined in: src/abstract/AbstractCollection.ts:175

Returns a sequential stream over spliterator().

Stream<E>

Queue.stream

AbstractCollection.stream


toArray(): E[]

Defined in: src/abstract/AbstractCollection.ts:41

Returns a new array of the elements in iteration order.

E[]

Queue.toArray

AbstractCollection.toArray

toArray<A>(generator): A

Defined in: src/abstract/AbstractCollection.ts:48

Copies the elements in iteration order into generator(size()) and returns that array.

A extends WritableArrayLike<E>

(length) => A

receives the element count and returns a plain or typed array of at least that length

A

IndexOutOfBoundsException if the generated typed array is too short

NullPointerException if generator or its result is null

Queue.toArray

AbstractCollection.toArray


toString(): string

Defined in: src/abstract/AbstractCollection.ts:199

Returns [e1, e2, ...] in iteration order; an element that is this collection prints as (this Collection).

string

Queue.toString

AbstractCollection.toString