Skip to content
Buy me a coffee

AbstractSequentialList

Defined in: src/abstract/AbstractSequentialList.ts:15

Skeleton implementation of the List interface for sequential (linked) storage: positional operations (get, set, add(index, e), removeAt, addAll(index, c)) walk listIterator(index), so each costs O(index).

A subclass implements listIterator(index) and size(). For a modifiable list, the list iterator must support set, add and remove; the class does its own modCount tracking in that iterator, incrementing modCount on each structural change and throwing ConcurrentModificationException when it changes behind the iterator. Do not add the RandomAccess brand.

E

new AbstractSequentialList<E>(): AbstractSequentialList<E>

AbstractSequentialList<E>

AbstractList.constructor

modCount: number = 0

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

Structural modification counter. Iterators, sublists and spliterators record it and throw ConcurrentModificationException when it changes behind them. Subclasses increment it once per structural change (add, remove, clear); set leaves it alone.

AbstractList.modCount

[INSPECT](): string

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

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

string

AbstractList.[INSPECT]


[iterator](): IterableIterator<E>

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

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

IterableIterator<E>

AbstractList.[iterator]


add(e): boolean

Defined in: src/abstract/AbstractList.ts:80

Appends e (via addAtIndex(size(), e)) and returns true.

E

boolean

UnsupportedOperationException if addAtIndex is not overridden

AbstractList.add

add(index, e): void

Defined in: src/abstract/AbstractList.ts:86

Inserts e at index (via addAtIndex), shifting later elements right.

number

E

void

IndexOutOfBoundsException if index < 0 || index > size() (when the subclass checks it)

UnsupportedOperationException if addAtIndex is not overridden

AbstractList.add


addAll(c): boolean

Defined in: src/abstract/AbstractList.ts:100

Appends the elements of c in its iteration order (via addAllAt); returns true if c was not empty.

Collection<E>

boolean

NullPointerException if c is null

AbstractList.addAll

addAll(index, c): boolean

Defined in: src/abstract/AbstractList.ts:106

Inserts the elements of c at index in its iteration order (via addAllAt); returns true if c was not empty.

number

Collection<E>

boolean

IndexOutOfBoundsException if index < 0 || index > size()

NullPointerException if c is null

AbstractList.addAll


addFirst(e): void

Defined in: src/abstract/AbstractList.ts:237

Inserts e at index 0, via addAtIndex.

E

void

UnsupportedOperationException if addAtIndex is not overridden

AbstractList.addFirst


addLast(e): void

Defined in: src/abstract/AbstractList.ts:245

Appends e at the end, via addAtIndex.

E

void

UnsupportedOperationException if addAtIndex is not overridden

AbstractList.addLast


clear(): void

Defined in: src/abstract/AbstractList.ts:152

Removes every element via removeRange(0, size()) (list-iterator remove calls).

void

UnsupportedOperationException if removeAt is not overridden and the list is not empty

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

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

AbstractList.containsAll


equals(o): boolean

Defined in: src/abstract/AbstractList.ts:293

Returns true if o is a List with equal elements in the same order (any List implementation).

unknown

boolean

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

AbstractList.forEach


get(index): E

Defined in: src/abstract/AbstractSequentialList.ts:27

Returns the element at index by walking a list iterator; O(index).

number

E

IndexOutOfBoundsException if index < 0 || index >= size()

AbstractList.get


getFirst(): E

Defined in: src/abstract/AbstractList.ts:253

Returns the element at index 0.

E

NoSuchElementException if the list is empty

AbstractList.getFirst


getLast(): E

Defined in: src/abstract/AbstractList.ts:262

Returns the element at index size() - 1.

E

NoSuchElementException if the list is empty

AbstractList.getLast


hashCode(): number

Defined in: src/abstract/AbstractList.ts:303

Returns 31 * h + hashCode(e) over the elements, starting at 1, so equal lists hash the same.

number

AbstractList.hashCode


indexOf(o): number

Defined in: src/abstract/AbstractList.ts:135

Returns the index of the first element equal to o, or -1; a forward scan with a list iterator.

unknown

number

AbstractList.indexOf


isEmpty(): boolean

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

Returns size() === 0.

boolean

AbstractList.isEmpty


iterator(): Iterator<E>

Defined in: src/abstract/AbstractSequentialList.ts:73

Returns an iterator over the elements in order; it is listIterator(), so it fails fast the same way.

Iterator<E>

AbstractList.iterator


lastIndexOf(o): number

Defined in: src/abstract/AbstractList.ts:142

Returns the index of the last element equal to o, or -1; a backward scan with a list iterator.

unknown

number

AbstractList.lastIndexOf


abstract listIterator(index?): ListIterator<E>

Defined in: src/abstract/AbstractSequentialList.ts:21

Returns a list iterator starting at index (default 0). Subclasses implement it; every positional operation is built on it.

number

ListIterator<E>

IndexOutOfBoundsException if index < 0 || index > size()

AbstractList.listIterator


parallelStream(): Stream<E>

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

Returns a stream over spliterator() flagged as parallel.

Stream<E>

AbstractList.parallelStream


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.

unknown

boolean

UnsupportedOperationException if the iterator does not support remove() and a match is found

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

AbstractList.removeAll


removeAt(index): E

Defined in: src/abstract/AbstractSequentialList.ts:55

Removes and returns the element at index through the list iterator’s remove.

number

E

IndexOutOfBoundsException if index < 0 || index >= size()

UnsupportedOperationException if the list iterator does not support remove

AbstractList.removeAt


removeFirst(): E

Defined in: src/abstract/AbstractList.ts:271

Removes and returns the element at index 0, via removeAt.

E

NoSuchElementException if the list is empty

AbstractList.removeFirst


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

AbstractList.removeIf


removeLast(): E

Defined in: src/abstract/AbstractList.ts:280

Removes and returns the last element, via removeAt.

E

NoSuchElementException if the list is empty

AbstractList.removeLast


removeRange(fromIndex, toIndex): void

Defined in: src/abstract/AbstractList.ts:160

Removes [fromIndex, toIndex). Public so views can delegate.

number

number

void

IndexOutOfBoundsException for a bad range, before anything is removed

AbstractList.removeRange


replaceAll(operator): void

Defined in: src/abstract/AbstractList.ts:211

Replaces each element with operator(element), through the list iterator’s set.

(e) => E

void

NullPointerException if operator is null

AbstractList.replaceAll


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

AbstractList.retainAll


reversed(): List<E>

Defined in: src/abstract/AbstractList.ts:286

Returns a live reverse-ordered view; writes through it reach this list. reversed().reversed() is this list.

List<E>

AbstractList.reversed


set(index, e): E

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

Replaces the element at index through the list iterator’s set and returns the old one.

number

E

E

IndexOutOfBoundsException if index < 0 || index >= size()

UnsupportedOperationException if the list iterator does not support set

AbstractList.set


abstract size(): number

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

Returns the number of elements. Subclasses implement it.

number

AbstractList.size


sort(c?): void

Defined in: src/abstract/AbstractList.ts:222

Sorts the list stably by c (natural ordering when null or omitted): sorts a copy, then writes it back with the list iterator’s set, so it is not a structural change.

Comparator<E> | null = null

void

ClassCastException if natural ordering meets values that cannot be compared

AbstractList.sort


spliterator(): Spliterator<E>

Defined in: src/abstract/AbstractList.ts:202

ORDERED|SIZED|SUBSIZED. RandomAccess lists get a late-binding, fail-fast, index-based spliterator that splits in halves; others one over iterator().

Spliterator<E>

AbstractList.spliterator


stream(): Stream<E>

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

Returns a sequential stream over spliterator().

Stream<E>

AbstractList.stream


subList(fromIndex, toIndex): List<E>

Defined in: src/abstract/AbstractList.ts:193

Returns a live view of [fromIndex, toIndex): changes through it write to this list, and a structural change made to this list directly makes the view throw ConcurrentModificationException. Carries the RandomAccess brand when this list does.

number

number

List<E>

IndexOutOfBoundsException if fromIndex < 0 or toIndex > size()

IllegalArgumentException if fromIndex > toIndex

AbstractList.subList


toArray(): E[]

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

Returns a new array of the elements in iteration order.

E[]

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

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

AbstractList.toString