A MutableList
implemented using a backing Array
.
Also:
Stack
, where the top of the stack is the last
element of the list, andQueue
, where the front of the queue is the first
element of the list and the back of the queue is the
last element of the list.The size of the backing Array
is called the capacity
of the ArrayList
. The capacity of a new instance is
specified by the given initialCapacity
. The capacity is
increased when size
exceeds the capacity. The new
capacity is the product of the current capacity and the
given growthFactor
.
no subtypes hierarchy
Constructors | |
ArrayList | Source Codeshared ArrayList(Integer initialCapacity = 0, Float growthFactor = ..., {Element*} elements = ...) Create a new Parameters:
|
copy | Source Codeshared copy(ArrayList<Element> arrayList, Float growthFactor = ...) Create a new Parameters:
|
ofSize | Source Codeshared ofSize(Integer size, Element element, Float growthFactor = ...) Create a new Parameters:
|
Attributes | |
back | Source Codeshared actual Element? back The element currently at the back of the
queue, or Refines Queue.back |
capacity | Source Codeshared Integer capacity The size of the backing array, which must be at least
as large as the |
first | Source Codeshared actual Element? first The first element returned by the iterator, if any, or
|
front | Source Codeshared actual Element? front The element currently at the front of the
queue, or Refines Queue.front |
hash | Source Codeshared actual Integer hash The hash value of the value, which allows the value to be an element of a hash-based set or key of a hash-based map. Implementations must respect the constraint that:
Therefore, a class which refines In general, Note that when executing on a Java Virtual Machine, the
64-bit |
lastIndex | Source Codeshared actual Integer? lastIndex The index of the last element of the list, or Refines List.lastIndex |
size | Source Codeshared actual Integer size The number of elements returned by the |
top | Source Codeshared actual Element? top The element currently at the top of the stack,
or Refines Stack.top |
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Collection<Element> |
Attributes inherited from: Correspondence<Key,Item> |
Attributes inherited from: Iterable<Element,Absent> |
Attributes inherited from: List<Element> |
Attributes inherited from: Queue<Element> |
Attributes inherited from: Stack<Element> |
Methods | |
accept | Source Codeshared actual Element? accept() Remove and return the element at the front of the queue. Refines Queue.accept |
add | Source Codeshared actual void add(Element element) Refines ListMutator.add |
addAll | Source Codeshared actual void addAll({Element*} elements) Refines ListMutator.addAll |
any | Source Codeshared actual Boolean any(Boolean selecting(Element element)) Determines if there is at least one element of this
stream that satisfies the given predicate
function ( Refines Iterable.any |
clear | Source Codeshared actual void clear() Remove every element from this list, leaving an empty list with no elements. Refines ListMutator.clear |
clone | Source Codeshared actual ArrayList<Element> clone() A shallow copy of this collection, that is, a collection with identical elements which does not change if this collection changes. If this collection is immutable, it is acceptable to return a reference to this collection. If this collection is mutable, a newly instantiated collection must be returned. |
contains | Source Codeshared actual Boolean contains(Object element) Returns For any instance element in c For most
However, it is possible to form a useful |
copyTo | Source Codeshared void copyTo(ArrayList<Element>|Array<Element?> destination, Integer sourcePosition = 0, Integer destinationPosition = 0, Integer length = ...) Efficiently copy the elements in the measure
The given
If the given Parameters:
Throws
|
count | Source Codeshared actual Integer count(Boolean selecting(Element element)) Produces the number of elements in this stream that
satisfy the given predicate function ( Refines Iterable.count |
delete | Source Codeshared actual Element? delete(Integer index) Remove the element at the specified |
deleteMeasure | Source Codeshared actual void deleteMeasure(Integer from, Integer length) Remove every element with an index in the measured
range Refines ListMutator.deleteMeasure |
deleteSpan | Source Codeshared actual void deleteSpan(Integer from, Integer to) Remove every element with an index in the spanned range
Refines ListMutator.deleteSpan |
each | Source Codeshared actual void each(void step(Element element)) Call the given function ( For example: words.each((word) { print(word.lowercased); print(word.uppercased); }); Has the same effect as the following for (word in words) { print(word.lowercased); print(word.uppercased); } For certain streams this method is highly efficient,
surpassing the performance of Refines Iterable.each |
equals | Source Codeshared actual Boolean equals(Object that) Determine if two values are equal. For any two non-null objects x == y Implementations should respect the constraints that:
Furthermore it is recommended that implementations
ensure that if A class which explicitly refines Note that an implementation of |
every | Source Codeshared actual Boolean every(Boolean selecting(Element element)) Determines if all elements of this stream satisfy the
given predicate function ( Refines Iterable.every |
find | Source Codeshared actual Element? find(Boolean selecting(Element&Object element)) The first element of this stream which is not null and
satisfies the given predicate function ( For example, the expression (-10..10).find(Integer.positive) evaluates to |
findAndRemoveFirst | Source Codeshared actual Element? findAndRemoveFirst(Boolean selecting(Element&Object element)) Remove the first element that satisfies the given
predicate function from this list,
returning the removed element, or Refines MutableList.findAndRemoveFirst |
findAndRemoveLast | Source Codeshared actual Element? findAndRemoveLast(Boolean selecting(Element&Object element)) Remove the last element that satisfies the given
predicate function from this list,
returning the removed element, or Refines MutableList.findAndRemoveLast |
findAndReplaceFirst | Source Codeshared actual Element? findAndReplaceFirst(Boolean selecting(Element&Object element), Element replacement) Replace the first element of this list that satisfies
the given predicate function with
the given Refines MutableList.findAndReplaceFirst |
findAndReplaceLast | Source Codeshared actual Element? findAndReplaceLast(Boolean selecting(Element&Object element), Element replacement) Replace the last element of this list that satisfies
the given predicate function with
the given Refines MutableList.findAndReplaceLast |
findLast | Source Codeshared actual Element? findLast(Boolean selecting(Element&Object element)) The last element of this stream which is not null and
satisfies the given predicate function ( For example, the expression (-10..10).findLast(3.divides) evaluates to |
firstOccurrence | Source Codeshared actual Integer? firstOccurrence(Element element, Integer from, Integer length) The first index in this list at which the given
value ( Refines SearchableList.firstOccurrence |
getFromFirst | Source Codeshared actual Element? getFromFirst(Integer index) The |
infill | Source Codeshared actual void infill(Element replacement) Replace all null values in this list with the given replacement value. |
insert | Source Codeshared actual void insert(Integer index, Element element) Parameters:
Refines ListMutator.insert |
insertAll | Source Codeshared actual void insertAll(Integer index, {Element*} elements) Insert the given Parameters:
Refines ListMutator.insertAll |
iterator | Source Codeshared actual Iterator<Element> iterator() An iterator for the elements belonging to this stream. If this is a nonempty stream with type |
lastOccurrence | Source Codeshared actual Integer? lastOccurrence(Element element, Integer from, Integer length) The last index in this list at which the given
value ( Refines SearchableList.lastOccurrence |
measure | Source Codeshared actual List<Element> measure(Integer from, Integer length) Obtain a measure containing the mapped values starting
from the given starting index ( For any ranged stream r[from:length] The measure should contain the given number ( When the given index does not belong to this ranged object, the behavior is implementation dependent. |
move | Source Codeshared actual default void move(Integer i, Integer j) Efficiently move the element of this list at the given source index to the given destination index, shifting every element falling between the two given indices by one position to accommodate the change of position. If the source index is larger than the destination index, elements are shifted toward the end of the list. If the source index is smaller than the destination index, elements are shifted toward the start of the list. If the given indices are identical, no change is made to the list. Parameters:
|
occurrences | Source Codeshared actual {Integer*} occurrences(Element element, Integer from, Integer length) The indexes in this list at which the given
value ( Refines SearchableList.occurrences |
occurs | Source Codeshared actual Boolean occurs(Element element, Integer from, Integer length) Determines if the given value ( Refines SearchableList.occurs |
occursAt | Source Codeshared actual Boolean occursAt(Integer index, Element element) Determines if the given value ( Refines SearchableList.occursAt |
offer | Source Codeshared actual void offer(Element element) Add a new element to the back of the queue. Refines Queue.offer |
pop | Source Codeshared actual Element? pop() Remove and return the element at the top of the stack. Refines Stack.pop |
prune | Source Codeshared actual Integer prune() Remove all null elements from this list, leaving a list with no null elements, returning the number of elements removed. |
push | Source Codeshared actual void push(Element element) Push a new element onto the top of the stack. Refines Stack.push |
reduce | Source Codeshared actual Result|Element|Null reduce<Result>(Result accumulating(Result|Element partial, Element element)) Beginning with the For an empty stream, For a stream with one element, { first }.reduce(f) == first For a given stream it.reduce(f) == f(it.exceptLast.reduce(f), it.last) For example, the expression (1..100).reduce(plus) results in the integer Refines Iterable.reduce |
remove | Source Codeshared actual Integer remove(Element&Object element) Remove all occurrences of the given value from this list, returning the number of elements removed. To remove just one occurrence of the given value, use
|
removeAll | Source Codeshared actual Integer removeAll({Element&Object*} elements) Remove all occurrences of every one of the given values from this list, returning the number of elements removed. Refines ListMutator.removeAll |
removeFirst | Source Codeshared actual Boolean removeFirst(Element&Object element) Remove the first occurrence of the given
value from this list, if any, returning
|
removeLast | Source Codeshared actual Boolean removeLast(Element&Object element) Remove the last occurrence of the given
value from this list, if any, returning
|
removeWhere | Source Codeshared actual Integer removeWhere(Boolean selecting(Element&Object element)) Remove every element that satisfies the given predicate function from this list, returning the number of elements that were removed. Refines MutableList.removeWhere |
replace | Source Codeshared actual Integer replace(Element&Object element, Element replacement) Replace all occurrences of the given value in this list with the given replacement value. To replace just one occurrence of the given value, use
|
replaceFirst | Source Codeshared actual Boolean replaceFirst(Element&Object element, Element replacement) Replace the first occurrence of the given
value in this list, if any, with the given
replacement value, returning |
replaceLast | Source Codeshared actual Boolean replaceLast(Element&Object element, Element replacement) Replace the last occurrence of the given
value in this list, if any, with the given
replacement value, returning |
replaceWhere | Source Codeshared actual Integer replaceWhere(Boolean selecting(Element&Object element), Element replacement) Replace every element in this list that satisfies the
given predicate function with the given
Refines MutableList.replaceWhere |
set | Source Codeshared actual void set(Integer index, Element element) Set the item associated with the given For any instance c[index] = item Parameters:
|
shrink | Source Codeshared void shrink() Reduce the capacity of the list to its current |
sortInPlace | Source Codeshared void sortInPlace(Comparison comparing(Element&Object x, Element&Object y)) Sorts the elements in this list according to the order induced by the given comparison function. Null elements are sorted to the end of the list. This operation modifies the list. |
span | Source Codeshared actual List<Element> span(Integer from, Integer to) Obtain a span containing the elements between the two given indices. For any ranged stream r[from..to] The span should contain elements of this stream,
starting from the element at the given starting
index ( When one or both of the given indices does not belong to this ranged stream, the behavior is implementation dependent. |
spanFrom | Source Codeshared actual List<Element> spanFrom(Integer from) Obtain a span containing the elements between the given
starting index ( For any ranged stream r[from...] The span should contain elements of this stream,
starting from the element at the given starting
index ( When the given index does not belong to this ranged stream, the behavior is implementation dependent. |
spanTo | Source Codeshared actual List<Element> spanTo(Integer to) Obtain a span containing the elements between the first
index of this ranged stream and given end index ( For any ranged stream r[...to] The span should contain elements of this stream, up to
the element at the given ending index ( When the given index does not belong to this ranged stream, the behavior is implementation dependent. |
swap | Source Codeshared actual default void swap(Integer i, Integer j) Given two indices within this list, swap the positions of the elements at these indices. If the two given indices are identical, no change is made to the list. Parameters:
|
truncate | Source Codeshared actual void truncate(Integer size) Truncate this list to the given Parameters:
Refines ListMutator.truncate |