List
Defined in: src/immutable/ImmutableCollections.ts:776
The list interface (ordered, index-based collection), declared under this name so List works both as a type and as the
factory object with of, copyOf and ofLazy.
Extends
Section titled “Extends”List<E>
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”ListType.[iterator]
Call Signature
Section titled “Call Signature”add(
e):boolean
Defined in: src/interfaces/List.ts:21
Appends e to the end of this list.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”boolean
always true
Throws
Section titled “Throws”UnsupportedOperationException if this list is unmodifiable
Throws
Section titled “Throws”NullPointerException if e is null and this list rejects null
Inherited from
Section titled “Inherited from”ListType.add
Call Signature
Section titled “Call Signature”add(
index,e):void
Defined in: src/interfaces/List.ts:27
Inserts e at index, shifting the element there and all later ones one position to the right.
Parameters
Section titled “Parameters”number
E
Returns
Section titled “Returns”void
Throws
Section titled “Throws”IndexOutOfBoundsException if index < 0 or index > size()
Throws
Section titled “Throws”UnsupportedOperationException if this list is unmodifiable
Inherited from
Section titled “Inherited from”ListType.add
addAll()
Section titled “addAll()”Call Signature
Section titled “Call Signature”addAll(
c):boolean
Defined in: src/interfaces/List.ts:34
Appends every element of c, in c’s iteration order.
Parameters
Section titled “Parameters”Collection<E>
Returns
Section titled “Returns”boolean
true if this list changed (c was not empty)
Throws
Section titled “Throws”NullPointerException if c is null
Throws
Section titled “Throws”UnsupportedOperationException if this list is unmodifiable
Inherited from
Section titled “Inherited from”ListType.addAll
Call Signature
Section titled “Call Signature”addAll(
index,c):boolean
Defined in: src/interfaces/List.ts:42
Inserts every element of c at index, in c’s iteration order, shifting later elements right.
Parameters
Section titled “Parameters”number
Collection<E>
Returns
Section titled “Returns”boolean
true if this list changed (c was not empty)
Throws
Section titled “Throws”IndexOutOfBoundsException if index < 0 or index > size()
Throws
Section titled “Throws”NullPointerException if c is null
Throws
Section titled “Throws”UnsupportedOperationException if this list is unmodifiable
Inherited from
Section titled “Inherited from”ListType.addAll
addFirst()
Section titled “addFirst()”addFirst(
e):void
Defined in: src/interfaces/Collection.ts:133
Adds e as the first element (for a set that already holds it, moves it to the front).
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”void
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable or sorted
Throws
Section titled “Throws”NullPointerException if e is null and this collection rejects null
Inherited from
Section titled “Inherited from”ListType.addFirst
addLast()
Section titled “addLast()”addLast(
e):void
Defined in: src/interfaces/Collection.ts:139
Adds e as the last element (for a set that already holds it, moves it to the end).
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”void
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable or sorted
Throws
Section titled “Throws”NullPointerException if e is null and this collection rejects null
Inherited from
Section titled “Inherited from”ListType.addLast
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”ListType.clear
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”ListType.contains
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”ListType.containsAll
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”ListType.equals
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”ListType.forEach
get(
index):E
Defined in: src/interfaces/List.ts:47
Returns the element at index.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”E
Throws
Section titled “Throws”IndexOutOfBoundsException if index < 0 or index >= size()
Inherited from
Section titled “Inherited from”ListType.get
getFirst()
Section titled “getFirst()”getFirst():
E
Defined in: src/interfaces/Collection.ts:144
Returns the first element.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if this collection is empty
Inherited from
Section titled “Inherited from”ListType.getFirst
getLast()
Section titled “getLast()”getLast():
E
Defined in: src/interfaces/Collection.ts:149
Returns the last element.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if this collection is empty
Inherited from
Section titled “Inherited from”ListType.getLast
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”ListType.hashCode
indexOf()
Section titled “indexOf()”indexOf(
o):number
Defined in: src/interfaces/List.ts:63
Returns the index of the first element equal to o (by Objects.equals), or -1 if there is none.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”ListType.indexOf
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”ListType.isEmpty
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”ListType.iterator
lastIndexOf()
Section titled “lastIndexOf()”lastIndexOf(
o):number
Defined in: src/interfaces/List.ts:65
Returns the index of the last element equal to o (by Objects.equals), or -1 if there is none.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”ListType.lastIndexOf
listIterator()
Section titled “listIterator()”listIterator(
index?):ListIterator<E>
Defined in: src/interfaces/List.ts:71
Returns a fail-fast list iterator starting at index: the first next() returns the element at index.
Parameters
Section titled “Parameters”index?
Section titled “index?”number
start position, 0 by default
Returns
Section titled “Returns”ListIterator<E>
Throws
Section titled “Throws”IndexOutOfBoundsException if index < 0 or index > size()
Inherited from
Section titled “Inherited from”ListType.listIterator
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”ListType.parallelStream
remove()
Section titled “remove()”remove(
o):boolean
Defined in: src/interfaces/Collection.ts:61
Removes one element equal to o, if present.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
true if an element was removed
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable
Throws
Section titled “Throws”NullPointerException if o is null and this collection rejects null
Inherited from
Section titled “Inherited from”ListType.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”ListType.removeAll
removeAt()
Section titled “removeAt()”removeAt(
index):E
Defined in: src/interfaces/List.ts:61
Removes the element at index, shifting later elements one position to the left.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”E
the removed element
Throws
Section titled “Throws”IndexOutOfBoundsException if index < 0 or index >= size()
Throws
Section titled “Throws”UnsupportedOperationException if this list is unmodifiable
Inherited from
Section titled “Inherited from”ListType.removeAt
removeFirst()
Section titled “removeFirst()”removeFirst():
E
Defined in: src/interfaces/Collection.ts:155
Removes and returns the first element.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if this collection is empty
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable
Inherited from
Section titled “Inherited from”ListType.removeFirst
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”ListType.removeIf
removeLast()
Section titled “removeLast()”removeLast():
E
Defined in: src/interfaces/Collection.ts:161
Removes and returns the last element.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if this collection is empty
Throws
Section titled “Throws”UnsupportedOperationException if this collection is unmodifiable
Inherited from
Section titled “Inherited from”ListType.removeLast
replaceAll()
Section titled “replaceAll()”replaceAll(
operator):void
Defined in: src/interfaces/List.ts:85
Replaces each element with the result of operator applied to it, in order.
Parameters
Section titled “Parameters”operator
Section titled “operator”(e) => E
Returns
Section titled “Returns”void
Throws
Section titled “Throws”NullPointerException if operator is null
Throws
Section titled “Throws”UnsupportedOperationException if this list does not support set
Inherited from
Section titled “Inherited from”ListType.replaceAll
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”ListType.retainAll
reversed()
Section titled “reversed()”reversed():
List<E>
Defined in: src/interfaces/List.ts:94
Returns a live reverse-ordered view: changes through either side are visible in the other. Random-access when this list is.
Returns
Section titled “Returns”List<E>
Inherited from
Section titled “Inherited from”ListType.reversed
set(
index,e):E
Defined in: src/interfaces/List.ts:54
Replaces the element at index with e. Not a structural change, so open iterators stay valid.
Parameters
Section titled “Parameters”number
E
Returns
Section titled “Returns”E
the element previously at index
Throws
Section titled “Throws”IndexOutOfBoundsException if index < 0 or index >= size()
Throws
Section titled “Throws”UnsupportedOperationException if this list does not support set
Inherited from
Section titled “Inherited from”ListType.set
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”ListType.size
sort()
Section titled “sort()”sort(
c?):void
Defined in: src/interfaces/List.ts:92
Sorts this list in place. The sort is stable: equal elements keep their relative order.
Parameters
Section titled “Parameters”Comparator<E> | null
the comparator; null or omitted means natural ordering
Returns
Section titled “Returns”void
Throws
Section titled “Throws”ClassCastException if natural ordering is used and the elements have none
Throws
Section titled “Throws”UnsupportedOperationException if this list does not support set
Inherited from
Section titled “Inherited from”ListType.sort
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”ListType.spliterator
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”ListType.stream
subList()
Section titled “subList()”subList(
fromIndex,toIndex):List<E>
Defined in: src/interfaces/List.ts:79
Returns a live view of the range [fromIndex, toIndex): changes through either side are visible in the other.
A structural change made to this list other than through the view makes the view fail fast
(ConcurrentModificationException). The view is random-access when this list is.
Parameters
Section titled “Parameters”fromIndex
Section titled “fromIndex”number
toIndex
Section titled “toIndex”number
Returns
Section titled “Returns”List<E>
Throws
Section titled “Throws”IndexOutOfBoundsException if fromIndex < 0 or toIndex > size()
Throws
Section titled “Throws”IllegalArgumentException if fromIndex > toIndex
Inherited from
Section titled “Inherited from”ListType.subList
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”ListType.toArray
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”ListType.toArray
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
Inherited from
Section titled “Inherited from”ListType.toString