KtMutableList<T> class abstract

A generic ordered collection of elements that supports adding and removing elements. @param E the type of elements contained in the list. The mutable list is invariant on its element type.

Implemented types
Available extensions

Constructors

KtMutableList.empty()
factory
KtMutableList.from([Iterable<T> elements = const []])
factory
KtMutableList.of([T arg0, T arg1, T arg2, T arg3, T arg4, T arg5, T arg6, T arg7, T arg8, T arg9])
factory

Properties

dart Iterable<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a dart:core Iterable
no setter
dart List<T>

Available on KtList<T>, provided by the KtListExtensions extension

Returns a read-only dart:core List
no setter
dart List<T>

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Creates a List instance that wraps the original KtList. It acts as a view.
no setter
hashCode int
The hash code for this object.
no setterinherited
iter Iterable<T>
Access to a Iterable to be used in for-loops
no setterinherited
lastIndex int

Available on KtList<T>, provided by the KtListExtensions extension

Returns the index of the last item in the list or -1 if the list is empty.
no setter
list List<T>
Deprecated, use asList or iter for loops
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int
Returns the size of the collection.
no setterinherited

Methods

add(T element) bool
Adds the specified element to the end of this list.
override
addAll(KtIterable<T> elements) bool
Adds all of the elements of the specified collection to the end of this list.
override
addAllAt(int index, KtCollection<T> elements) bool
Inserts all of the elements in the specified collection elements into this list at the specified index.
addAt(int index, T element) → void
Inserts an element into the list at the specified index.
all(bool predicate(T element)) bool

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns true if all elements match the given predicate.
any([bool predicate(T element)?]) bool

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns true if at least one element matches the given predicate.
asIterable() KtIterable<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns this collection as an Iterable.
asList() List<T>
Creates a List instance that wraps the original KtList. It acts as a view.
override
associate<K, V>(KtPair<K, V> transform(T)) KtMap<K, V>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a Map containing key-value pairs provided by transform function applied to elements of the given collection.
associateBy<K>(K keySelector(T)) KtMap<K, T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a Map containing the elements from the given collection indexed by the key returned from keySelector function applied to each element.
associateByTo<K, V, M extends KtMutableMap<K, V>>(M destination, K keySelector(T), [V valueTransform(T)?]) → M

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function and and value is provided by the valueTransform function applied to elements of the given collection.
associateByTransform<K, V>(K keySelector(T), V valueTransform(T)) KtMap<K, V>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a Map containing the elements from the given collection indexed by the key returned from keySelector function applied to each element. The element can be transformed with valueTransform.
associateTo<K, V, M extends KtMutableMap<K, V>>(M destination, KtPair<K, V> transform(T)) → M

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each element of the given collection.
associateWith<V>(V valueSelector(T)) KtMap<T, V>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a Map where keys are elements from the given collection and values are produced by the valueSelector function applied to each element.
associateWithTo<V, M extends KtMutableMap>(M destination, V valueSelector(T)) → M

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Populates and returns the destination mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the valueSelector function applied to that key.
average() double

Available on KtIterable<T>, provided by the KtNumIterableExtension extension

Returns the average or null if there are no elements.
averageBy(num selector(T)) double

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns an average value produced by selector function applied to each element in the collection.
cast<R>() KtList<R>

Available on KtList<T>, provided by the KtListExtensions extension

Provides a view of this KtList as an list of R instances.
cast<R>() KtIterable<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Provides a view of this KtIterable as an iterable of R instances.
chunked(int size) KtList<KtList<T>>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Splits this collection into a list of lists each not exceeding the given size.
chunkedTransform<R>(int size, R transform(KtList<T>)) KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Splits this collection into several lists each not exceeding the given size and applies the given transform function to an each.
clear() → void
Removes all elements from this collection.
override
contains(T element) bool
Checks if the specified element is contained in this collection.
inherited
contains(T element) bool

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns true if element is found in the collection.
containsAll(KtCollection<T> elements) bool
Checks if all elements in the specified collection are contained in this collection.
inherited
count([bool predicate(T)?]) int

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the number of elements matching the given predicate or the number of elements when predicate = null.
distinct() KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing only distinct elements from the given collection.
distinctBy<K>(K selector(T)) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing only elements from the given collection having distinct keys returned by the given selector function.
drop(int n) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements except first n elements.
dropLast(int n) KtList<T>

Available on KtList<T>, provided by the KtListExtensions extension

Returns a list containing all elements except last n elements.
dropLastWhile(bool predicate(T)) KtList<T>

Available on KtList<T>, provided by the KtListExtensions extension

Returns a list containing all elements except last elements that satisfy the given predicate.
dropWhile(bool predicate(T)) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements except first elements that satisfy the given predicate.
elementAt(int index) → T

Available on KtList<T>, provided by the KtListExtensions extension

Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this list.
elementAt(int index) → T

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this collection.
elementAtOrElse(int index, T defaultValue(int index)) → T

Available on KtList<T>, provided by the KtListExtensions extension

Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this list.
elementAtOrElse(int index, T defaultValue(int)) → T

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this collection.
elementAtOrNull(int index) → T?

Available on KtList<T>, provided by the KtListExtensions extension

Returns an element at the given index or null if the index is out of bounds of this collection.
elementAtOrNull(int index) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns an element at the given index or null if the index is out of bounds of this collection.
fill(T value) → void

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Fills the list with the provided value.
filter(bool predicate(T)) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing only elements matching the given predicate.
filterIndexed(bool predicate(int index, T)) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing only elements matching the given predicate. @param predicate function that takes the index of an element and the element itself and returns the result of predicate evaluation on the element.
filterIndexedTo<C extends KtMutableCollection>(C destination, bool predicate(int index, T)) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Appends all elements matching the given predicate to the given destination. @param predicate function that takes the index of an element and the element itself and returns the result of predicate evaluation on the element.
filterIsInstance<R>() KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements that are instances of specified type parameter R.
filterNot(bool predicate(T)) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements not matching the given predicate.
filterNotNull() KtList<T>

Available on KtIterable<T?>, provided by the RequireNoNullsKtIterableExtension extension

Returns a list containing all elements that are not null.
filterNotNullTo<C extends KtMutableCollection>(C destination) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Appends all elements that are not null to the given destination.
filterNotTo<C extends KtMutableCollection>(C destination, bool predicate(T)) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Appends all elements not matching the given predicate to the given destination.
filterTo<C extends KtMutableCollection>(C destination, bool predicate(T)) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Appends all elements matching the given predicate to the given destination.
find(bool predicate(T)) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the first element matching the given predicate, or null if no such element was found.
findLast(bool predicate(T)) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the last element matching the given predicate, or null if no such element was found.
first([bool predicate(T)?]) → T

Available on KtList<T>, provided by the KtListExtensions extension

Returns first element.
first([bool predicate(T)?]) → T

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns first element.
firstNotNullOf<R>(R? transform(T?)) → R

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the first non-null value after applying the given transform function, throwing a NoSuchElementException exception if there is no such value.
firstNotNullOfOrNull<R>(R? transform(T?)) → R?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the first non-null value after applying the given transform function; null will be returned if there is no such value.
firstOrNull([bool predicate(T)?]) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the first element (matching predicate when provided), or null if the collection is empty.
flatMap<R>(KtIterable<R> transform(T)) KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a single list of all elements yielded from results of transform function being invoked on each element of original collection.
flatMapIndexed<R>(KtIterable<R> transform(int index, T)) KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a single list of all elements yielded from results of transform function being invoked on each element and its index in the original collection.
flatMapIndexedTo<R, C extends KtMutableCollection<R>>(C destination, KtIterable<R> transform(int index, T)) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Appends all elements yielded from results of transform function being invoked on each element and its index in the original collection, to the given destination.
flatMapTo<R, C extends KtMutableCollection<R>>(C destination, KtIterable<R> transform(T)) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Appends all elements yielded from results of transform function being invoked on each element of original collection, to the given destination.
flatten() KtList<T>

Available on KtIterable<KtIterable<T>>, provided by the NestedKtIterableExtensions extension

Returns a single list of all elements from all collections in the given collection.
fold<R>(R initial, R operation(R acc, T)) → R

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each element.
foldIndexed<R>(R initial, R operation(int index, R acc, T)) → R

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each element with its index in the original collection. @param operation function that takes the index of an element, current accumulator value and the element itself, and calculates the next accumulator value.
foldRight<R>(R initial, R operation(T, R acc)) → R

Available on KtList<T>, provided by the KtListExtensions extension

Accumulates value starting with initial value and applying operation from right to left to each element and current accumulator value.
foldRightIndexed<R>(R initial, R operation(int index, T, R acc)) → R

Available on KtList<T>, provided by the KtListExtensions extension

Accumulates value starting with initial value and applying operation from right to left to each element with its index in the original list and current accumulator value. @param operation function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value.
forEach(void action(T element)) → void

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Performs the given action on each element.
forEachIndexed(void action(int index, T element)) → void

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Performs the given action on each element, providing sequential index with the element. @param action function that takes the index of an element and the element itself and performs the desired action on the element.
get(int index) → T
Returns the element at the specified index in the list or throw IndexOutOfBoundsException
inherited
getOrElse(int index, T defaultValue(int)) → T

Available on KtList<T>, provided by the KtListExtensions extension

Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this list.
getOrNull(int index) → T?

Available on KtList<T>, provided by the KtListExtensions extension

Returns an element at the given index or null if the index is out of bounds of this list.
groupBy<K>(K keySelector(T)) KtMap<K, KtList<T>>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Groups elements of the original collection by the key returned by the given keySelector function applied to each element and returns a map where each group key is associated with a list of corresponding elements.
groupByTo<K, M extends KtMutableMap<K, KtMutableList>>(M destination, K keySelector(T)) → M

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Groups elements of the original collection by the key returned by the given keySelector function applied to each element and puts to the destination map each group key associated with a list of corresponding elements.
groupByToTransform<K, V, M extends KtMutableMap<K, KtMutableList<V>>>(M destination, K keySelector(T), V valueTransform(T)) → M

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Groups values returned by the valueTransform function applied to each element of the original collection by the key returned by the given keySelector function applied to the element and puts to the destination map each group key associated with a list of corresponding values.
groupByTransform<K, V>(K keySelector(T), V valueTransform(T)) KtMap<K, KtList<V>>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Groups values returned by the valueTransform function applied to each element of the original collection by the key returned by the given keySelector function applied to the element and returns a map where each group key is associated with a list of corresponding values.
indexOf(T element) int

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns first index of element, or -1 if the collection does not contain element.
indexOf(T element) int
Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.
inherited
indexOfFirst(bool predicate(T)) int

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns index of the first element matching the given predicate, or -1 if the collection does not contain such element.
indexOfLast(bool predicate(T)) int

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns index of the last element matching the given predicate, or -1 if the collection does not contain such element.
intersect(KtIterable<T> other) KtSet<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a set containing all elements that are contained by both this set and the specified collection.
isEmpty() bool
Returns true if the collection is empty (contains no elements), false otherwise.
inherited
isNotEmpty() bool

Available on KtCollection<T>, provided by the KtCollectionExtensions extension

Returns true if the collection is not empty.
iterator() KtMutableIterator<T>
Returns an iterator over the elements of this object.
inherited
joinToString({String separator = ", ", String prefix = "", String postfix = "", int limit = -1, String truncated = "...", String transform(T)?}) String

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Creates a string from all the elements separated using separator and using the given prefix and postfix if supplied.
last([bool predicate(T)?]) → T

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the last element matching the given predicate. @throws NoSuchElementException if no such element is found.
last([bool predicate(T)?]) → T

Available on KtList<T>, provided by the KtListExtensions extension

Returns the last element matching the given predicate. @throws NoSuchElementException if no such element is found.
lastIndexOf(T element) int

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns last index of element, or -1 if the collection does not contain element.
lastIndexOf(T element) int
Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.
inherited
lastOrNull([bool predicate(T)?]) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the last element matching the given predicate, or null if no such element was found.
listIterator([int index = 0]) KtMutableListIterator<T>
Returns a list iterator over the elements in this list (in proper sequence), starting at the specified index or 0 by default.
override
map<R>(R transform(T)) KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing the results of applying the given transform function to each element in the original collection.
mapIndexed<R>(R transform(int index, T)) KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing the results of applying the given transform function to each element and its index in the original collection. @param transform function that takes the index of an element and the element itself and returns the result of the transform applied to the element.
mapIndexedNotNull<R>(R? transform(int index, T)) KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing only the non-null results of applying the given transform function to each element and its index in the original collection. @param transform function that takes the index of an element and the element itself and returns the result of the transform applied to the element.
mapIndexedNotNullTo<R, C extends KtMutableCollection<R>>(C destination, R? transform(int index, T)) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Applies the given transform function to each element and its index in the original collection and appends only the non-null results to the given destination. @param transform function that takes the index of an element and the element itself and returns the result of the transform applied to the element.
mapIndexedTo<R, C extends KtMutableCollection<R>>(C destination, R transform(int index, T)) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Applies the given transform function to each element and its index in the original collection and appends the results to the given destination. @param transform function that takes the index of an element and the element itself and returns the result of the transform applied to the element.
mapNotNull<R>(R? transform(T)) KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing the results of applying the given transform function to each element in the original collection.
mapNotNullTo<R, C extends KtMutableCollection<R>>(C destination, R? transform(T)) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Applies the given transform function to each element in the original collection and appends only the non-null results to the given destination.
mapTo<R, C extends KtMutableCollection<R>>(C destination, R transform(T)) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Applies the given transform function to each element of the original collection and appends the results to the given destination.
max() → T?

Available on KtIterable<T>, provided by the KtNumIterableExtension extension

Returns the largest element or null if there are no elements.
max() → T?

Available on KtIterable<T>, provided by the KtComparableIterableExtension extension

Returns the largest element or null if there are no elements.
maxBy<R extends Comparable>(R selector(T)) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the first element yielding the largest value of the given function or null if there are no elements.
maxOf<R extends Comparable>(R selector(T)) → R

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the largest value among all values produced by selector function applied to each element in the collection.
maxOrNull() → T?

Available on KtIterable<T>, provided by the KtNumIterableExtension extension

Returns the largest element or null if there are no elements.
maxOrNull() → T?

Available on KtIterable<T>, provided by the KtComparableIterableExtension extension

Returns the largest element or null if there are no elements.
maxWith(Comparator<T> comparator) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the first element having the largest value according to the provided comparator or null if there are no elements.
min() → T?

Available on KtIterable<T>, provided by the KtComparableIterableExtension extension

Returns the smallest element or null if there are no elements.
min() → T?

Available on KtIterable<T>, provided by the KtNumIterableExtension extension

Returns the smallest element or null if there are no elements.
minBy<R extends Comparable>(R selector(T)) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the first element yielding the smallest value of the given function or null if there are no elements.
minOf<R extends Comparable>(R selector(T)) → R

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the smallest value among all values produced by selector function applied to each element in the array.
minOrNull() → T?

Available on KtIterable<T>, provided by the KtComparableIterableExtension extension

Returns the smallest element or null if there are no elements.
minOrNull() → T?

Available on KtIterable<T>, provided by the KtNumIterableExtension extension

Returns the smallest element or null if there are no elements.
minus(KtIterable<T> elements) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements of the original collection except the elements contained in the given elements collection.
minusElement(T element) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements of the original collection without the first occurrence of the given element.
minWith(Comparator<T> comparator) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the first element having the smallest value according to the provided comparator or null if there are no elements.
none([bool predicate(T)?]) bool

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns true if the collection has no elements or no elements match the given predicate.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onEach(void action(T item)) KtIterable<T>

Available on KtIterable<T>, provided by the ChainableKtIterableExtensions extension

Performs the given action on each element. Use with cascade syntax to return self.
onEach(void action(T item)) KtList<T>

Available on KtList<T>, provided by the ChainableKtListExtensions extension

Performs the given action on each element. Use with cascade syntax to return self.
onEachIndexed(void action(int index, T item)) KtList<T>

Available on KtList<T>, provided by the ChainableKtListExtensions extension

Performs the given action on each element, providing sequential index with the element, and returns the collection itself afterwards.
onEachIndexed(void action(int index, T item)) KtIterable<T>

Available on KtIterable<T>, provided by the ChainableKtIterableExtensions extension

Performs the given action on each element, providing sequential index with the element, and returns the collection itself afterwards.
orEmpty() KtCollection<T>

Available on KtCollection<T>?, provided by the NullableKtCollectionExtensions extension

Returns this KtCollection if it's not null and the empty list otherwise.
orEmpty() KtList<T>

Available on KtList<T>?, provided by the NullableKtListExtensions extension

Returns this KtList if it's not null and the empty list otherwise.
partition(bool predicate(T)) KtPair<KtList<T>, KtList<T>>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Splits the original collection into pair of lists, where first list contains elements for which predicate yielded true, while second list contains elements for which predicate yielded false.
plus(KtIterable<T> elements) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements of the original collection and then all elements of the given elements collection.
plusElement(T element) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements of the original collection and then the given element.
random([Random? random]) → T

Available on KtCollection<T>, provided by the KtCollectionExtensions extension

Returns a random element from this collection.
randomOrNull([Random? random]) → T?

Available on KtCollection<T>, provided by the KtCollectionExtensions extension

Returns a random element from this collection.
reduce<S>(S operation(S acc, T)) → S

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each element.
reduceIndexed<S>(S operation(int index, S acc, T)) → S

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each element with its index in the original collection. @param operation function that takes the index of an element, current accumulator value and the element itself and calculates the next accumulator value.
reduceIndexedOrNull<S>(S operation(int index, S acc, T)) → S?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each element with its index in the original collection.
reduceOrNull<S>(S operation(S acc, T)) → S?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each element.
reduceRight<S>(S operation(T, S acc)) → S

Available on KtList<T>, provided by the KtListExtensions extension

Accumulates value starting with last element and applying operation from right to left to each element and current accumulator value.
reduceRightIndexed<S>(S operation(int index, T, S acc)) → S

Available on KtList<T>, provided by the KtListExtensions extension

Accumulates value starting with last element and applying operation from right to left to each element with its index in the original list and current accumulator value. @param operation function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value.
remove(T element) bool
Removes a single instance of the specified element from this collection, if it is present.
override
removeAll(KtIterable<T> elements) bool
Removes all of this collection's elements that are also contained in the specified collection.
override
removeAllWhere(bool predicate(T)) bool

Available on KtMutableIterable<T>, provided by the KtMutableIterableExtensions extension

Removes all elements from this KtMutableIterable that match the given predicate.
removeAt(int index) → T
Removes and returns the element at the specified index from the list.
removeFirst() → T

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Removes the first element from this mutable list.
removeFirstOrNull() → T?

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Removes the first element from this mutable list.
removeLast() → T

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Removes the last element from this mutable list.
removeLastOrNull() → T?

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Removes the last element from this mutable list.
requireNoNulls() KtIterable<T>

Available on KtIterable<T?>, provided by the RequireNoNullsKtIterableExtension extension

Returns an original collection containing all the non-null elements, throwing an ArgumentError if there are any null elements.
requireNoNulls() KtList<T>

Available on KtList<T?>, provided by the RequireNoNullsKtListExtension extension

Returns an original collection containing all the non-null elements, throwing an ArgumentError if there are any null elements.
retainAll(KtIterable<T> elements) bool
Retains only the elements in this collection that are contained in the specified collection.
override
retainAllWhere(bool predicate(T)) bool

Available on KtMutableIterable<T>, provided by the KtMutableIterableExtensions extension

Retains only elements of this KtMutableIterable that match the given predicate
reverse() → void

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Reverses elements in the list in-place.
reversed() KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list with elements in reversed order.
runningReduce<S>(S operation(S acc, T)) KtList<S>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing successive accumulation values generated by applying operation from left to right to each element and current accumulator value that starts with the first element of this collection.
runningReduceIndexed<S>(S operation(int index, S acc, T)) KtList<S>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing successive accumulation values generated by applying operation from left to right to each element, its index in the original collection and current accumulator value that starts with the first element of this collection.
set(int index, T element) → T
Replaces the element at the specified position in this list with the specified element.
shuffle([Random? random]) → void

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Shuffles elements in the list.
shuffled([Random? random]) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a new list with the elements of this list randomly shuffled.
single([bool predicate(T)?]) → T

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the single element matching the given predicate, or throws an exception if the list is empty or has more than one element.
single([bool predicate(T)?]) → T

Available on KtList<T>, provided by the KtListExtensions extension

Returns the single element matching the given predicate, or throws an exception if the list is empty or has more than one element.
singleOrNull([bool predicate(T)?]) → T?

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the single element matching the given predicate, or null if element was not found or more than one element was found.
singleOrNull([bool predicate(T)?]) → T?

Available on KtList<T>, provided by the KtListExtensions extension

Returns the single element matching the given predicate, or null if element was not found or more than one element was found.
slice(KtIterable<int> indices) KtList<T>

Available on KtList<T>, provided by the KtListExtensions extension

Returns a list containing elements at specified indices.
sortBy<R extends Comparable>(R selector(T)) → void

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Sorts elements in the list in-place according to natural sort order of the value returned by specified selector function.
sortByDescending<R extends Comparable>(R selector(T)) → void

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Sorts elements in the list in-place descending according to natural sort order of the value returned by specified selector function.
sorted() KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of all elements sorted according to their natural sort order.
sortedBy<R extends Comparable>(R selector(T)) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of all elements sorted according to natural sort order of the value returned by specified selector function.
sortedByDescending<R extends Comparable>(R selector(T)) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of all elements sorted descending according to natural sort order of the value returned by specified selector function.
sortedDescending() KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of all elements sorted descending according to their natural sort order.
sortedWith(Comparator<T> comparator) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of all elements sorted according to the specified comparator.
sortWith(Comparator<T> comparator) → void

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Sorts elements in the list in-place according to the specified comparator
subList(int fromIndex, int toIndex) KtMutableList<T>
Returns a view of the portion of this list between the specified fromIndex (inclusive) and toIndex (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa.
override
subtract(KtIterable<T> other) KtSet<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a set containing all elements that are contained by this collection and not contained by the specified collection.
sum() int

Available on KtIterable<int>, provided by the KtIntIterableExtension extension

Returns the sum of all elements in the collection.
sum() double

Available on KtIterable<double>, provided by the KtDoubleIterableExtension extension

Returns the sum of all elements in the collection.
sumBy<R extends num>(R selector(T)) → R

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the sum of all values produced by selector function applied to each element in the collection.
sumByDouble(double selector(T)) double

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns the sum of all values produced by selector function applied to each element in the collection.
sumOf<R extends num>(R selector(T)) → R

Available on KtCollection<T>, provided by the KtCollectionExtensions extension

Returns the sum of all elements in this collection.
swap(int indexA, int indexB) → void

Available on KtMutableList<T>, provided by the KtMutableListExtensions extension

Swaps the elements at the specified positions in the specified list. (If the specified positions are equal, invoking this method leaves the list unchanged.)
take(int n) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing first n elements.
takeLast(int n) KtList<T>

Available on KtList<T>, provided by the KtListExtensions extension

Returns a list containing last n elements.
takeLastWhile(bool predicate(T)) KtList<T>

Available on KtList<T>, provided by the KtListExtensions extension

Returns a list containing last elements satisfying the given predicate.
takeWhile(bool predicate(T)) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing first elements satisfying the given predicate.
toCollection<C extends KtMutableCollection>(C destination) → C

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Appends all elements to the given destination collection.
toHashSet() KtMutableSet<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a HashSet of all elements.
toList() KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a KtList containing all elements.
toMutableList() KtMutableList<T>

Available on KtCollection<T>, provided by the KtCollectionExtensions extension

Returns a KtMutableList filled with all elements of this collection.
toMutableList() KtMutableList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a KtMutableList filled with all elements of this collection.
toMutableSet() KtMutableSet<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a mutable set containing all distinct elements from the given collection.
toSet() KtSet<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a KtSet of all elements.
toString() String
A string representation of this object.
inherited
union(KtIterable<T> other) KtSet<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a set containing all distinct elements from both collections.
unzip() KtPair<KtList<T>, KtList<R>>

Available on KtIterable<KtPair<T, R>>, provided by the UnzipKtIterableExtensions extension

Returns a pair of lists, where first list is built from the first values of each pair from this collection, second list is built from the second values of each pair from this collection.
windowed(int size, {int step = 1, bool partialWindows = false}) KtList<KtList<T>>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of snapshots of the window of the given size sliding along this collection with the given step, where each snapshot is a list.
windowedTransform<R>(int size, R transform(KtList<T>), {int step = 1, bool partialWindows = false}) KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of results of applying the given transform function to an each list representing a view over the window of the given size sliding along this collection with the given step.
zip<R>(KtIterable<R> other) KtList<KtPair<T, R>>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of pairs built from the elements of this collection and other collection with the same index. The returned list has length of the shortest collection.
zipTransform<R, V>(KtIterable<R> other, V transform(T a, R b)) KtList<V>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of values built from the elements of this collection and the other collection with the same index using the provided transform function applied to each pair of elements. The returned list has length of the shortest collection.
zipWithNext() KtList<KtPair<T, T>>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list of pairs of each two adjacent elements in this collection.
zipWithNextTransform<R>(R transform(T a, T b)) KtList<R>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing the results of applying the given transform function to an each pair of two adjacent elements in this collection.

Operators

operator +(KtIterable<T> elements) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements of the original collection and then all elements of the given elements collection.
operator -(KtIterable<T> elements) KtList<T>

Available on KtIterable<T>, provided by the KtIterableExtensions extension

Returns a list containing all elements of the original collection except the elements contained in the given elements collection.
operator ==(Object other) bool
The equality operator.
inherited
operator [](int index) → T
Returns the element at the specified index in the list or throw IndexOutOfBoundsException
inherited
operator []=(int index, T element) → void
Replaces the element at the specified position in this list with the specified element.