Vector
Defined in: src/list/Vector.ts:27
Legacy growable array list: an ArrayList plus the old element-style methods (elementAt,
addElement, elements(), …), a reported capacity() with capacityIncrement, and
ArrayIndexOutOfBoundsException for bad indexes. It is meant for porting code that uses
them; new code should use ArrayList.
Complexity, null policy (null and undefined allowed) and index-order iteration are those of
ArrayList. JS is single-threaded, so there is no synchronization.
Extends
Section titled “Extends”ArrayList<E>
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”E
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Vector<
E>():Vector<E>
Defined in: src/list/Vector.ts:34
Creates an empty vector with capacity 10 that doubles when outgrown.
Returns
Section titled “Returns”Vector<E>
Overrides
Section titled “Overrides”Constructor
Section titled “Constructor”new Vector<
E>(initialCapacity,capacityIncrement?):Vector<E>
Defined in: src/list/Vector.ts:41
Creates an empty vector with the given reported capacity.
Parameters
Section titled “Parameters”initialCapacity
Section titled “initialCapacity”number
initial value of capacity()
capacityIncrement?
Section titled “capacityIncrement?”number
amount the capacity grows by when outgrown; 0 or less (the default) means it doubles
Returns
Section titled “Returns”Vector<E>
Throws
Section titled “Throws”IllegalArgumentException if initialCapacity is negative or not an integer
Overrides
Section titled “Overrides”Constructor
Section titled “Constructor”new Vector<
E>(c):Vector<E>
Defined in: src/list/Vector.ts:46
Creates a vector holding the elements of c, in its iteration order; capacity() is their count.
Parameters
Section titled “Parameters”Collection<E>
Returns
Section titled “Returns”Vector<E>
Throws
Section titled “Throws”NullPointerException if c is null or undefined
Overrides
Section titled “Overrides”Properties
Section titled “Properties”capacityIncrement
Section titled “capacityIncrement”
readonlycapacityIncrement:number
Defined in: src/list/Vector.ts:31
Amount capacity() grows by when outgrown; 0 or less means it doubles. Fixed at construction.
modCount
Section titled “modCount”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.
Inherited from
Section titled “Inherited from”Accessors
Section titled “Accessors”[RANDOM_ACCESS]
Section titled “[RANDOM_ACCESS]”Get Signature
Section titled “Get Signature”get [RANDOM_ACCESS]():
true
Defined in: src/list/ArrayList.ts:81
Marker for O(1) positional access; always true.
Returns
Section titled “Returns”true
Inherited from
Section titled “Inherited from”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
Inherited from
Section titled “Inherited from”[iterator]()
Section titled “[iterator]()”[iterator]():
IterableIterator<E>
Defined in: src/list/ArrayList.ts:423
Returns a JS iterator over the elements in index order, for for...of and spread; fail-fast.
Returns
Section titled “Returns”IterableIterator<E>
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”add(
e):boolean
Defined in: src/list/Vector.ts:98
Appends e to the end of this vector, in amortized O(1), growing capacity() when outgrown.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”boolean
always true
Overrides
Section titled “Overrides”Call Signature
Section titled “Call Signature”add(
index,e):void
Defined in: src/list/Vector.ts:104
Inserts e at index, shifting later elements one position to the right. O(n − index); grows
capacity() when outgrown.
Parameters
Section titled “Parameters”number
E
Returns
Section titled “Returns”void
Throws
Section titled “Throws”ArrayIndexOutOfBoundsException if index < 0 or index > size()
Overrides
Section titled “Overrides”addAll()
Section titled “addAll()”Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”Collection<E>
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”NullPointerException if c is null
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”number
Collection<E>
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”IndexOutOfBoundsException if index < 0 || index > size()
Throws
Section titled “Throws”NullPointerException if c is null
Inherited from
Section titled “Inherited from”addElement()
Section titled “addElement()”addElement(
e):void
Defined in: src/list/Vector.ts:298
Appends e; same as add(e) but returns nothing.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”void
addFirst()
Section titled “addFirst()”addFirst(
e):void
Defined in: src/abstract/AbstractList.ts:237
Inserts e at index 0, via addAtIndex.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”void
Throws
Section titled “Throws”UnsupportedOperationException if addAtIndex is not overridden
Inherited from
Section titled “Inherited from”addLast()
Section titled “addLast()”addLast(
e):void
Defined in: src/abstract/AbstractList.ts:245
Appends e at the end, via addAtIndex.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”void
Throws
Section titled “Throws”UnsupportedOperationException if addAtIndex is not overridden
Inherited from
Section titled “Inherited from”capacity()
Section titled “capacity()”capacity():
number
Defined in: src/list/Vector.ts:183
Returns the reported capacity: how many elements fit before it next grows. It is bookkeeping for ported code; the engine manages the real storage.
Returns
Section titled “Returns”number
clear()
Section titled “clear()”clear():
void
Defined in: src/list/ArrayList.ts:266
Removes all elements. Truncates the backing array, so no references to the removed elements are kept.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”clone()
Section titled “clone()”clone():
this
Defined in: src/list/Vector.ts:144
Returns a shallow, independent copy whose capacity() equals its size; capacityIncrement is kept.
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”contains()
Section titled “contains()”contains(
o):boolean
Defined in: src/list/ArrayList.ts:200
Returns true if this list contains an element equal to o (by Objects.equals). O(n) scan; null is allowed.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”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
Inherited from
Section titled “Inherited from”copyInto()
Section titled “copyInto()”copyInto(
anArray):void
Defined in: src/list/Vector.ts:233
Copies the elements, in index order, into anArray from index 0. A plain array grows if too
short; a fixed-size (typed) array that is too short throws IndexOutOfBoundsException.
Parameters
Section titled “Parameters”anArray
Section titled “anArray”Returns
Section titled “Returns”void
Throws
Section titled “Throws”NullPointerException if anArray is null
elementAt()
Section titled “elementAt()”elementAt(
index):E
Defined in: src/list/Vector.ts:274
Returns the element at index; same as get. O(1).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”E
Throws
Section titled “Throws”ArrayIndexOutOfBoundsException if index < 0 or index >= size()
elements()
Section titled “elements()”elements():
Enumeration<E> &Iterable<E,any,any>
Defined in: src/list/Vector.ts:241
Returns a legacy Enumeration of the elements in index order. It is index-based and not
fail-fast; it is also JS-iterable and adapts to an Iterator through asIterator().
Returns
Section titled “Returns”Enumeration<E> & Iterable<E, any, any>
ensureCapacity()
Section titled “ensureCapacity()”ensureCapacity(
minCapacity):void
Defined in: src/list/Vector.ts:162
Raises capacity() to at least minCapacity: it grows by capacityIncrement (or doubles when
that is 0 or less), or straight to minCapacity if that is larger. Real storage is unaffected.
Any positive request counts as a structural change, so open iterators fail fast afterwards.
Parameters
Section titled “Parameters”minCapacity
Section titled “minCapacity”number
Returns
Section titled “Returns”void
Throws
Section titled “Throws”IllegalArgumentException if minCapacity is not an integer
Overrides
Section titled “Overrides”equals()
Section titled “equals()”equals(
o):boolean
Defined in: src/list/ArrayList.ts:428
Returns true if o is a List of any class with equal elements in the same order. O(n).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”firstElement()
Section titled “firstElement()”firstElement():
E
Defined in: src/list/Vector.ts:283
Returns the first element; same as getFirst.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if the vector is empty
forEach()
Section titled “forEach()”forEach(
action):void
Defined in: src/list/ArrayList.ts:276
Calls action for each element, in index 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 list
Inherited from
Section titled “Inherited from”get(
index):E
Defined in: src/list/Vector.ts:61
Returns the element at index. O(1).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”E
Throws
Section titled “Throws”ArrayIndexOutOfBoundsException if index < 0 or index >= size()
Overrides
Section titled “Overrides”getFirst()
Section titled “getFirst()”getFirst():
E
Defined in: src/list/ArrayList.ts:386
Returns the first element. O(1).
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if the list is empty
Inherited from
Section titled “Inherited from”getLast()
Section titled “getLast()”getLast():
E
Defined in: src/list/ArrayList.ts:395
Returns the last element. O(1).
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if the list is empty
Inherited from
Section titled “Inherited from”hashCode()
Section titled “hashCode()”hashCode():
number
Defined in: src/list/ArrayList.ts:454
Returns the list hash code, h = 31 * h + hash(e) from 1 in 32-bit arithmetic, consistent with equals. O(n).
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”indexOf()
Section titled “indexOf()”indexOf(
o,index?):number
Defined in: src/list/Vector.ts:192
Returns the index of the first element equal to o, searching forward from index
(from 0 when omitted), or -1. O(n).
Parameters
Section titled “Parameters”unknown
index?
Section titled “index?”number
Returns
Section titled “Returns”number
Throws
Section titled “Throws”IndexOutOfBoundsException if index < 0
Overrides
Section titled “Overrides”insertElementAt()
Section titled “insertElementAt()”insertElementAt(
e,index):void
Defined in: src/list/Vector.ts:330
Inserts e at index; same as add(index, e) with the arguments swapped. O(n − index).
Parameters
Section titled “Parameters”E
number
Returns
Section titled “Returns”void
Throws
Section titled “Throws”ArrayIndexOutOfBoundsException if index < 0 or index > size()
isEmpty()
Section titled “isEmpty()”isEmpty():
boolean
Defined in: src/list/ArrayList.ts:110
Returns true if this list has no elements. O(1).
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”iterator()
Section titled “iterator()”iterator():
Iterator<E>
Defined in: src/list/ArrayList.ts:402
Returns a fail-fast iterator over the elements in index order. Its remove is O(n), like removeAt.
Returns
Section titled “Returns”Iterator<E>
Inherited from
Section titled “Inherited from”lastElement()
Section titled “lastElement()”lastElement():
E
Defined in: src/list/Vector.ts:292
Returns the last element; same as getLast.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if the vector is empty
lastIndexOf()
Section titled “lastIndexOf()”lastIndexOf(
o,index?):number
Defined in: src/list/Vector.ts:206
Returns the index of the last element equal to o, searching backward from index
(from the end when omitted), or -1. O(n).
Parameters
Section titled “Parameters”unknown
index?
Section titled “index?”number
Returns
Section titled “Returns”number
Throws
Section titled “Throws”IndexOutOfBoundsException if index >= size()
Overrides
Section titled “Overrides”listIterator()
Section titled “listIterator()”listIterator(
index?):ListIterator<E>
Defined in: src/list/ArrayList.ts:412
Returns a fail-fast list iterator starting at index: the first next() returns the element at
index. Its set is O(1); its add and remove are O(n), like the positional methods.
Parameters
Section titled “Parameters”index?
Section titled “index?”number = 0
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”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>
Inherited from
Section titled “Inherited from”remove()
Section titled “remove()”remove(
o):boolean
Defined in: src/list/Vector.ts:307
Removes the first element equal to o (by Objects.equals), if present. O(n). Counts as a
structural change even when o is not found, so open iterators fail fast afterwards.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
true if an element was removed
Overrides
Section titled “Overrides”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
Inherited from
Section titled “Inherited from”removeAllElements()
Section titled “removeAllElements()”removeAllElements():
void
Defined in: src/list/Vector.ts:346
Removes every element; same as clear. capacity() is unchanged.
Returns
Section titled “Returns”void
removeAt()
Section titled “removeAt()”removeAt(
index):E
Defined in: src/list/Vector.ts:82
Removes the element at index, shifting later elements one position to the left. O(n − index).
Counts as a structural change even when index is invalid.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”E
the removed element
Throws
Section titled “Throws”ArrayIndexOutOfBoundsException if index < 0 or index >= size()
Overrides
Section titled “Overrides”removeElement()
Section titled “removeElement()”removeElement(
o):boolean
Defined in: src/list/Vector.ts:313
Removes the first element equal to o; same as remove(o). O(n).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
removeElementAt()
Section titled “removeElementAt()”removeElementAt(
index):void
Defined in: src/list/Vector.ts:321
Removes the element at index; same as removeAt but returns nothing. O(n − index).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Throws
Section titled “Throws”ArrayIndexOutOfBoundsException if index < 0 or index >= size()
removeFirst()
Section titled “removeFirst()”removeFirst():
E
Defined in: src/abstract/AbstractList.ts:271
Removes and returns the element at index 0, via removeAt.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if the list is empty
Inherited from
Section titled “Inherited from”removeIf()
Section titled “removeIf()”removeIf(
filter):boolean
Defined in: src/list/ArrayList.ts:321
Removes every element for which filter returns true, in O(n) with one compaction pass. Every
element is tested before anything is removed, so a throwing predicate, or one that modifies the list,
leaves the list unchanged.
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”ConcurrentModificationException if filter structurally modifies this list
Inherited from
Section titled “Inherited from”removeLast()
Section titled “removeLast()”removeLast():
E
Defined in: src/abstract/AbstractList.ts:280
Removes and returns the last element, via removeAt.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if the list is empty
Inherited from
Section titled “Inherited from”removeRange()
Section titled “removeRange()”removeRange(
fromIndex,toIndex):void
Defined in: src/list/ArrayList.ts:303
Removes [fromIndex, toIndex). Public so views can delegate.
Parameters
Section titled “Parameters”fromIndex
Section titled “fromIndex”number
toIndex
Section titled “toIndex”number
Returns
Section titled “Returns”void
Throws
Section titled “Throws”IndexOutOfBoundsException for a bad range, before anything is removed
Inherited from
Section titled “Inherited from”replaceAll()
Section titled “replaceAll()”replaceAll(
operator):void
Defined in: src/list/ArrayList.ts:351
Replaces each element with the result of operator applied to it, in order. O(n). Counts as a
structural change: open iterators fail fast afterwards.
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”ConcurrentModificationException if operator structurally modifies this list
Inherited from
Section titled “Inherited from”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
Inherited from
Section titled “Inherited from”reversed()
Section titled “reversed()”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.
Returns
Section titled “Returns”List<E>
Inherited from
Section titled “Inherited from”set(
index,e):E
Defined in: src/list/Vector.ts:71
Replaces the element at index with e. O(1); not a structural change.
Parameters
Section titled “Parameters”number
E
Returns
Section titled “Returns”E
the element previously at index
Throws
Section titled “Throws”ArrayIndexOutOfBoundsException if index < 0 or index >= size()
Overrides
Section titled “Overrides”setElementAt()
Section titled “setElementAt()”setElementAt(
e,index):void
Defined in: src/list/Vector.ts:340
Replaces the element at index; same as set(index, e) with the arguments swapped, but returns
nothing. O(1), not a structural change.
Parameters
Section titled “Parameters”E
number
Returns
Section titled “Returns”void
Throws
Section titled “Throws”ArrayIndexOutOfBoundsException if index < 0 or index >= size()
setSize()
Section titled “setSize()”setSize(
newSize):void
Defined in: src/list/Vector.ts:219
Sets the size: truncates the vector, or pads it with null elements. Raises capacity() if needed.
Parameters
Section titled “Parameters”newSize
Section titled “newSize”number
Returns
Section titled “Returns”void
Throws
Section titled “Throws”ArrayIndexOutOfBoundsException if newSize < 0 or not an integer
size()
Section titled “size()”size():
number
Defined in: src/list/ArrayList.ts:105
Returns the number of elements. O(1).
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”sort()
Section titled “sort()”sort(
c?):void
Defined in: src/list/ArrayList.ts:369
Sorts this list in place. The sort is stable (equal elements keep their order) and O(n log n). Counts as a structural change: open iterators fail fast afterwards.
Parameters
Section titled “Parameters”Comparator<E> | null = 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”ConcurrentModificationException if the comparator structurally modifies this list
Inherited from
Section titled “Inherited from”spliterator()
Section titled “spliterator()”spliterator():
Spliterator<E>
Defined in: src/list/ArrayList.ts:418
Returns a spliterator over the elements, used to build streams: ORDERED | SIZED | SUBSIZED, late-binding, fail-fast, splits in halves.
Returns
Section titled “Returns”Spliterator<E>
Inherited from
Section titled “Inherited from”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>
Inherited from
Section titled “Inherited from”subList()
Section titled “subList()”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.
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”toArray()
Section titled “toArray()”Call Signature
Section titled “Call Signature”toArray():
E[]
Defined in: src/list/ArrayList.ts:255
Returns a new array with all elements, in index order. Changing the array does not affect this list. O(n).
Returns
Section titled “Returns”E[]
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”toArray<
A>(generator):A
Defined in: src/list/ArrayList.ts:260
Fills an array created by generator(size()) with the elements in index order, and returns it. O(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/list/ArrayList.ts:465
Returns the elements in index order as [a, b, c]; an element that is this list prints as (this Collection).
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”trimToSize()
Section titled “trimToSize()”trimToSize():
void
Defined in: src/list/Vector.ts:174
Sets capacity() to size(). Counts as a structural change, so open iterators fail fast afterwards.
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”
staticof<E>(…xs):Vector<E>
Defined in: src/list/Vector.ts:136
Creates a vector holding xs in argument order. capacity() starts at 10 and grows once,
as for a bulk add, if xs needs more. Called on a subclass, returns an instance of it.
Type Parameters
Section titled “Type Parameters”E
Parameters
Section titled “Parameters”…E[]
Returns
Section titled “Returns”Vector<E>