AbstractCollection
Defined in: src/abstract/AbstractCollection.ts:22
Skeleton implementation of the Collection interface, built entirely on iterator() and size().
A read-only subclass implements those two methods and inherits everything else: contains, toArray,
the bulk operations, forEach, stream(), spliterator(), for..of and toString(). To make it modifiable,
override add(e) (which throws UnsupportedOperationException by default) and return an iterator whose
remove() works; remove, removeIf, removeAll, retainAll and clear all go through it.
There is no modCount here: fail-fast behaviour is whatever the subclass’s iterator provides.
equals/hashCode are identity-based; override them (or extend AbstractList/AbstractSet) for value equality.
The defaults are linear scans; override any method the storage can do faster.
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”E
Implements
Section titled “Implements”Collection<E>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AbstractCollection<
E>():AbstractCollection<E>
Returns
Section titled “Returns”AbstractCollection<E>
Methods
Section titled “Methods”[INSPECT]()
Section titled “[INSPECT]()”[INSPECT]():
string
Defined in: src/abstract/AbstractCollection.ts:195
Node’s util.inspect hook: console.log prints the toString() form.
Returns
Section titled “Returns”string
[iterator]()
Section titled “[iterator]()”[iterator]():
IterableIterator<E>
Defined in: src/abstract/AbstractCollection.ts:164
Makes the collection usable with for..of and spread; walks iterator().
Returns
Section titled “Returns”IterableIterator<E>
Implementation of
Section titled “Implementation of”add(
_e):boolean
Defined in: src/abstract/AbstractCollection.ts:60
Adds e; returns true if the collection changed. Not supported by default.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”UnsupportedOperationException unless a subclass overrides it
Implementation of
Section titled “Implementation of”addAll()
Section titled “addAll()”addAll(
c):boolean
Defined in: src/abstract/AbstractCollection.ts:96
Calls add for each element of a snapshot of c (so addAll(this) terminates); returns true if any call
changed the collection.
Parameters
Section titled “Parameters”Collection<E>
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”NullPointerException if c is null
Throws
Section titled “Throws”UnsupportedOperationException if add is not supported and c is not empty
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
void
Defined in: src/abstract/AbstractCollection.ts:145
Removes every element by walking the iterator and calling its remove().
Returns
Section titled “Returns”void
Throws
Section titled “Throws”UnsupportedOperationException if the iterator does not support remove() and the collection is not empty
Implementation of
Section titled “Implementation of”contains()
Section titled “contains()”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().
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”containsAll()
Section titled “containsAll()”containsAll(
c):boolean
Defined in: src/abstract/AbstractCollection.ts:83
Returns true if this collection contains every element of c (calls contains for each).
Parameters
Section titled “Parameters”Collection<unknown>
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”NullPointerException if c is null
Implementation of
Section titled “Implementation of”equals()
Section titled “equals()”equals(
o):boolean
Defined in: src/abstract/AbstractCollection.ts:185
Identity by default; List/Set/Map subclasses override with value equality.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”forEach()
Section titled “forEach()”forEach(
action):void
Defined in: src/abstract/AbstractCollection.ts:157
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
Implementation of
Section titled “Implementation of”hashCode()
Section titled “hashCode()”hashCode():
number
Defined in: src/abstract/AbstractCollection.ts:190
Identity hash by default, consistent with the identity equals.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”isEmpty()
Section titled “isEmpty()”isEmpty():
boolean
Defined in: src/abstract/AbstractCollection.ts:29
Returns size() === 0.
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”iterator()
Section titled “iterator()”
abstractiterator():Iterator<E>
Defined in: src/abstract/AbstractCollection.ts:24
Returns an iterator over the elements. Subclasses implement it; its remove() backs every removal method.
Returns
Section titled “Returns”Iterator<E>
Implementation of
Section titled “Implementation of”parallelStream()
Section titled “parallelStream()”parallelStream():
Stream<E>
Defined in: src/abstract/AbstractCollection.ts:180
Returns a stream over spliterator() flagged as parallel.
Returns
Section titled “Returns”Stream<E>
Implementation of
Section titled “Implementation of”remove()
Section titled “remove()”remove(
o):boolean
Defined in: src/abstract/AbstractCollection.ts:68
Removes the first element equal to o through the iterator’s remove(); returns true if one was removed.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”UnsupportedOperationException if the iterator does not support remove() and a match is found
Implementation of
Section titled “Implementation of”removeAll()
Section titled “removeAll()”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.
Parameters
Section titled “Parameters”Collection<unknown>
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”NullPointerException if c is null
Implementation of
Section titled “Implementation of”removeIf()
Section titled “removeIf()”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.
Parameters
Section titled “Parameters”filter
Section titled “filter”(e) => boolean
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”NullPointerException if filter is null
Implementation of
Section titled “Implementation of”retainAll()
Section titled “retainAll()”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.
Parameters
Section titled “Parameters”Collection<unknown>
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”NullPointerException if c is null
Implementation of
Section titled “Implementation of”size()
Section titled “size()”
abstractsize():number
Defined in: src/abstract/AbstractCollection.ts:26
Returns the number of elements. Subclasses implement it.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”spliterator()
Section titled “spliterator()”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.
Returns
Section titled “Returns”Spliterator<E>
Implementation of
Section titled “Implementation of”stream()
Section titled “stream()”stream():
Stream<E>
Defined in: src/abstract/AbstractCollection.ts:175
Returns a sequential stream over spliterator().
Returns
Section titled “Returns”Stream<E>
Implementation of
Section titled “Implementation of”toArray()
Section titled “toArray()”Call Signature
Section titled “Call Signature”toArray():
E[]
Defined in: src/abstract/AbstractCollection.ts:41
Returns a new array of the elements in iteration order.
Returns
Section titled “Returns”E[]
Implementation of
Section titled “Implementation of”Call Signature
Section titled “Call Signature”toArray<
A>(generator):A
Defined in: src/abstract/AbstractCollection.ts:48
Copies the elements in iteration order into generator(size()) and returns that array.
Type Parameters
Section titled “Type Parameters”A extends WritableArrayLike<E>
Parameters
Section titled “Parameters”generator
Section titled “generator”(length) => A
receives the element count and returns a plain or typed array of at least that length
Returns
Section titled “Returns”A
Throws
Section titled “Throws”IndexOutOfBoundsException if the generated typed array is too short
Throws
Section titled “Throws”NullPointerException if generator or its result is null
Implementation of
Section titled “Implementation of”toString()
Section titled “toString()”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).
Returns
Section titled “Returns”string