Package kotlin.collections

Collection types, such as Iterable, Collection, List, Set, Map and related top-level and extension functions.

Types

Common
JVM
JS
Native
1.1

AbstractCollection

Provides a skeletal implementation of the read-only Collection interface.

abstract class AbstractCollection<out E> : Collection<E>
Common
JVM
JS
Native
1.0

AbstractIterator

A base class to simplify implementing iterators so that implementations only have to implement computeNext to implement the iterator, calling done when the iteration is complete.

abstract class AbstractIterator<T> : Iterator<T>
Common
JVM
JS
Native
1.1

AbstractList

Provides a skeletal implementation of the read-only List interface.

abstract class AbstractList<out E> : 
    AbstractCollection<E>,
    List<E>
Common
JVM
JS
Native
1.1

AbstractMap

Provides a skeletal implementation of the read-only Map interface.

abstract class AbstractMap<K, out V> : Map<K, V>

AbstractMutableCollection

Provides a skeletal implementation of the MutableCollection interface.

JVM
1.1
abstract class AbstractMutableCollection<E> : 
    MutableCollection<E>,
    AbstractCollection<E>
JS
1.1
abstract class AbstractMutableCollection<E> : 
    AbstractCollection<E>,
    MutableCollection<E>
Native
1.3
abstract class AbstractMutableCollection<E> : 
    MutableCollection<E>,
    AbstractCollection<E>

AbstractMutableList

Provides a skeletal implementation of the MutableList interface.

Common
1.0
abstract class AbstractMutableList<E> : MutableList<E>
JVM
1.1
abstract class AbstractMutableList<E> : 
    MutableList<E>,
    AbstractList<E>
JS
Native
1.1
abstract class AbstractMutableList<E> : 
    AbstractMutableCollection<E>,
    MutableList<E>

AbstractMutableMap

Provides a skeletal implementation of the MutableMap interface.

Common
1.0
abstract class AbstractMutableMap<K, V> : MutableMap<K, V>
JVM
1.1
abstract class AbstractMutableMap<K, V> : 
    MutableMap<K, V>,
    AbstractMap<K, V>
JS
Native
1.1
abstract class AbstractMutableMap<K, V> : 
    AbstractMap<K, V>,
    MutableMap<K, V>

AbstractMutableSet

Provides a skeletal implementation of the MutableSet interface.

Common
1.0
abstract class AbstractMutableSet<E> : MutableSet<E>
JVM
1.1
abstract class AbstractMutableSet<E> : 
    MutableSet<E>,
    AbstractSet<E>
JS
1.1
abstract class AbstractMutableSet<E> : 
    AbstractMutableCollection<E>,
    MutableSet<E>
Native
1.1
abstract class AbstractMutableSet<E> : 
    AbstractSet<E>,
    MutableSet<E>
Common
JVM
JS
Native
1.1

AbstractSet

Provides a skeletal implementation of the read-only Set interface.

abstract class AbstractSet<out E> : 
    AbstractCollection<E>,
    Set<E>

ArrayList

Provides a MutableList implementation, which uses a resizable array as its backing storage.

Common
1.0
class ArrayList<E> : MutableList<E>, RandomAccess
JVM
1.1
typealias ArrayList<E> = ArrayList<E>
JS
1.1
open class ArrayList<E> : 
    AbstractMutableList<E>,
    MutableList<E>,
    RandomAccess
Native
1.3
class ArrayList<E> : 
    MutableList<E>,
    RandomAccess,
    AbstractMutableCollection<E>
Common
JVM
JS
Native
1.0

BooleanIterator

An iterator over a sequence of values of type Boolean.

abstract class BooleanIterator : Iterator<Boolean>
Common
JVM
JS
Native
1.0

ByteIterator

An iterator over a sequence of values of type Byte.

abstract class ByteIterator : Iterator<Byte>
Common
JVM
JS
Native
1.0

CharIterator

An iterator over a sequence of values of type Char.

abstract class CharIterator : Iterator<Char>
Common
JVM
JS
Native
1.0

Collection

A generic collection of elements. Methods in this interface support only read-only access to the collection; read/write access is supported through the MutableCollection interface.

interface Collection<out E> : Iterable<E>
Common
JVM
JS
Native
1.0

DoubleIterator

An iterator over a sequence of values of type Double.

abstract class DoubleIterator : Iterator<Double>
Common
JVM
JS
Native
1.0

FloatIterator

An iterator over a sequence of values of type Float.

abstract class FloatIterator : Iterator<Float>
Common
JVM
JS
Native
1.1

Grouping

Represents a source of elements with a keyOf function, which can be applied to each element to get its key.

interface Grouping<T, out K>

HashMap

Hash table based implementation of the MutableMap interface.

Common
Native
1.0
class HashMap<K, V> : MutableMap<K, V>
JVM
1.1
typealias HashMap<K, V> = HashMap<K, V>
JS
1.1
open class HashMap<K, V> : 
    AbstractMutableMap<K, V>,
    MutableMap<K, V>

HashSet

The implementation of the MutableSet interface, backed by a HashMap instance.

Common
1.0
class HashSet<E> : MutableSet<E>
JVM
1.1
typealias HashSet<E> = HashSet<E>
JS
1.1
open class HashSet<E> : AbstractMutableSet<E>, MutableSet<E>
Native
1.3
class HashSet<E> : 
    MutableSet<E>,
    AbstractMutableCollection<E>,
    KonanSet<E>
Common
JVM
JS
Native
1.0

IndexedValue

Data class representing a value from a collection or sequence, along with its index in that collection or sequence.

data class IndexedValue<out T>
Common
JVM
JS
Native
1.0

IntIterator

An iterator over a sequence of values of type Int.

abstract class IntIterator : Iterator<Int>
Common
JVM
JS
Native
1.0

Iterable

Classes that inherit from this interface can be represented as a sequence of elements that can be iterated over.

interface Iterable<out T>
Common
JVM
JS
Native
1.0

Iterator

An iterator over a collection or another entity that can be represented as a sequence of elements. Allows to sequentially access the elements.

interface Iterator<out T>

LinkedHashMap

Hash table based implementation of the MutableMap interface, which additionally preserves the insertion order of entries during the iteration.

Common
1.0
class LinkedHashMap<K, V> : MutableMap<K, V>
JVM
1.1
typealias LinkedHashMap<K, V> = LinkedHashMap<K, V>
JS
1.1
open class LinkedHashMap<K, V> : 
    HashMap<K, V>,
    MutableMap<K, V>
Native
1.3
typealias LinkedHashMap<K, V> = HashMap<K, V>

LinkedHashSet

The implementation of the MutableSet interface, backed by a LinkedHashMap instance.

Common
1.0
class LinkedHashSet<E> : MutableSet<E>
JVM
1.1
typealias LinkedHashSet<E> = LinkedHashSet<E>
JS
1.1
open class LinkedHashSet<E> : HashSet<E>, MutableSet<E>
Native
1.3
typealias LinkedHashSet<V> = HashSet<V>
Common
JVM
JS
Native
1.0

List

A generic ordered collection of elements. Methods in this interface support only read-only access to the list; read/write access is supported through the MutableList interface.

interface List<out E> : Collection<E>
Common
JVM
JS
Native
1.0

ListIterator

An iterator over a collection that supports indexed access.

interface ListIterator<out T> : Iterator<T>
Common
JVM
JS
Native
1.0

LongIterator

An iterator over a sequence of values of type Long.

abstract class LongIterator : Iterator<Long>
Common
JVM
JS
Native
1.0

Map

A collection that holds pairs of objects (keys and values) and supports efficiently retrieving the value corresponding to each key. Map keys are unique; the map holds only one value for each key. Methods in this interface support only read-only access to the map; read-write access is supported through the MutableMap interface.

interface Map<K, out V>
Common
JVM
JS
Native
1.0

MutableCollection

A generic collection of elements that supports adding and removing elements.

interface MutableCollection<E> : 
    Collection<E>,
    MutableIterable<E>
Common
JVM
JS
Native
1.0

MutableIterable

Classes that inherit from this interface can be represented as a sequence of elements that can be iterated over and that supports removing elements during iteration.

interface MutableIterable<out T> : Iterable<T>
Common
JVM
JS
Native
1.0

MutableIterator

An iterator over a mutable collection. Provides the ability to remove elements while iterating.

interface MutableIterator<out T> : Iterator<T>
Common
JVM
JS
Native
1.0

MutableList

A generic ordered collection of elements that supports adding and removing elements.

interface MutableList<E> : List<E>, MutableCollection<E>
Common
JVM
JS
Native
1.0

MutableListIterator

An iterator over a mutable collection that supports indexed access. Provides the ability to add, modify and remove elements while iterating.

interface MutableListIterator<T> : 
    ListIterator<T>,
    MutableIterator<T>
Common
JVM
JS
Native
1.0

MutableMap

A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving the value corresponding to each key. Map keys are unique; the map holds only one value for each key.

interface MutableMap<K, V> : Map<K, V>
Common
JVM
JS
Native
1.0

MutableSet

A generic unordered collection of elements that does not support duplicate elements, and supports adding and removing elements.

interface MutableSet<E> : Set<E>, MutableCollection<E>

RandomAccess

Marker interface indicating that the List implementation supports fast indexed access.

Common
JS
Native
1.0
interface RandomAccess
JVM
1.1
typealias RandomAccess = RandomAccess
Common
JVM
JS
Native
1.0

Set

A generic unordered collection of elements that does not support duplicate elements. Methods in this interface support only read-only access to the set; read/write access is supported through the MutableSet interface.

interface Set<out E> : Collection<E>
Common
JVM
JS
Native
1.0

ShortIterator

An iterator over a sequence of values of type Short.

abstract class ShortIterator : Iterator<Short>
Common
JVM
JS
Native
1.3

UByteIterator

An iterator over a sequence of values of type UByte.

abstract class UByteIterator : Iterator<UByte>
Common
JVM
JS
Native
1.3

UIntIterator

An iterator over a sequence of values of type UInt.

abstract class UIntIterator : Iterator<UInt>
Common
JVM
JS
Native
1.3

ULongIterator

An iterator over a sequence of values of type ULong.

abstract class ULongIterator : Iterator<ULong>
Common
JVM
JS
Native
1.3

UShortIterator

An iterator over a sequence of values of type UShort.

abstract class UShortIterator : Iterator<UShort>

Extensions for External Classes

Properties

Common
JVM
JS
Native
1.0

indices

Returns the range of valid indices for the array.

val <T> any_array<T>.indices: IntRange

Returns an IntRange of the valid indices for this collection.

val Collection<*>.indices: IntRange
Common
JVM
JS
Native
1.0

lastIndex

Returns the last valid index for the array.

val <T> any_array<T>.lastIndex: Int

Returns the index of the last item in the list or -1 if the list is empty.

val <T> List<T>.lastIndex: Int

Functions

Common
JVM
JS
Native
1.0

addAll

Adds all elements of the given elements collection to this MutableCollection.

fun <T> MutableCollection<in T>.addAll(
    elements: Iterable<T>
): Boolean

Adds all elements of the given elements sequence to this MutableCollection.

fun <T> MutableCollection<in T>.addAll(
    elements: Sequence<T>
): Boolean

Adds all elements of the given elements array to this MutableCollection.

fun <T> MutableCollection<in T>.addAll(
    elements: Array<out T>
): Boolean
Common
JVM
JS
Native
1.1

aggregate

Groups elements from the Grouping source by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map.

fun <T, K, R> Grouping<T, K>.aggregate(
    operation: (key: K, accumulator: R?, element: T, first: Boolean) -> R
): Map<K, R>
Common
JVM
JS
Native
1.1

aggregateTo

Groups elements from the Grouping source by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given destination map.

fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.aggregateTo(
    destination: M,
    operation: (key: K, accumulator: R?, element: T, first: Boolean) -> R
): M
Common
JVM
JS
Native
1.0

all

Returns true if all elements match the given predicate.

fun <T> Array<out T>.all(predicate: (T) -> Boolean): Boolean
fun ByteArray.all(predicate: (Byte) -> Boolean): Boolean
fun ShortArray.all(predicate: (Short) -> Boolean): Boolean
fun IntArray.all(predicate: (Int) -> Boolean): Boolean
fun LongArray.all(predicate: (Long) -> Boolean): Boolean
fun FloatArray.all(predicate: (Float) -> Boolean): Boolean
fun DoubleArray.all(predicate: (Double) -> Boolean): Boolean
fun BooleanArray.all(
    predicate: (Boolean) -> Boolean
): Boolean
fun CharArray.all(predicate: (Char) -> Boolean): Boolean
fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean

Returns true if all entries match the given predicate.

fun <K, V> Map<out K, V>.all(
    predicate: (Entry<K, V>) -> Boolean
): Boolean
Common
JVM
JS
Native
1.0

any

Returns true if array has at least one element.

fun <T> any_array<T>.any(): Boolean

Returns true if at least one element matches the given predicate.

fun <T> Array<out T>.any(predicate: (T) -> Boolean): Boolean
fun ByteArray.any(predicate: (Byte) -> Boolean): Boolean
fun ShortArray.any(predicate: (Short) -> Boolean): Boolean
fun IntArray.any(predicate: (Int) -> Boolean): Boolean
fun LongArray.any(predicate: (Long) -> Boolean): Boolean
fun FloatArray.any(predicate: (Float) -> Boolean): Boolean
fun DoubleArray.any(predicate: (Double) -> Boolean): Boolean
fun BooleanArray.any(
    predicate: (Boolean) -> Boolean
): Boolean
fun CharArray.any(predicate: (Char) -> Boolean): Boolean
fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean

Returns true if collection has at least one element.

fun <T> Iterable<T>.any(): Boolean

Returns true if map has at least one entry.

fun <K, V> Map<out K, V>.any(): Boolean

Returns true if at least one entry matches the given predicate.

fun <K, V> Map<out K, V>.any(
    predicate: (Entry<K, V>) -> Boolean
): Boolean
Common
JVM
JS
Native
1.0

arrayListOf

Returns an empty new ArrayList.

fun <T> arrayListOf(): ArrayList<T>

Returns a new ArrayList with the given elements.

fun <T> arrayListOf(vararg elements: T): ArrayList<T>
Common
JVM
JS
Native
1.3

asByteArray

Returns an array of type ByteArray, which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array.

fun UByteArray.asByteArray(): ByteArray
Common
JVM
JS
Native
1.3

asIntArray

Returns an array of type IntArray, which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array.

fun UIntArray.asIntArray(): IntArray
Common
JVM
JS
Native
1.0

asIterable

Creates an Iterable instance that wraps the original array returning its elements when being iterated.

fun <T> any_array<T>.asIterable(): Iterable<T>

Returns this collection as an Iterable.

fun <T> Iterable<T>.asIterable(): Iterable<T>

Creates an Iterable instance that wraps the original map returning its entries when being iterated.

fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>>
Common
JVM
JS
Native
1.0

asList

Returns a List that wraps the original array.

fun <T> any_array<T>.asList(): List<T>
Common
JVM
JS
Native
1.3

asLongArray

Returns an array of type LongArray, which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array.

fun ULongArray.asLongArray(): LongArray
Common
JVM
JS
Native
1.0

asReversed

Returns a reversed read-only view of the original List. All changes made in the original list will be reflected in the reversed one.

fun <T> List<T>.asReversed(): List<T>

Returns a reversed mutable view of the original mutable List. All changes made in the original list will be reflected in the reversed one and vice versa.

fun <T> MutableList<T>.asReversed(): MutableList<T>
Common
JVM
JS
Native
1.0

asSequence

Creates a Sequence instance that wraps the original array returning its elements when being iterated.

fun <T> any_array<T>.asSequence(): Sequence<T>

Creates a Sequence instance that wraps the original collection returning its elements when being iterated.

fun <T> Iterable<T>.asSequence(): Sequence<T>

Creates a Sequence instance that wraps the original map returning its entries when being iterated.

fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>>
Common
JVM
JS
Native
1.3

asShortArray

Returns an array of type ShortArray, which is a view of this array where each element is a signed reinterpretation of the corresponding element of this array.

fun UShortArray.asShortArray(): ShortArray
Common
JVM
JS
Native
1.0

associate

Returns a Map containing key-value pairs provided by transform function applied to elements of the given array.

fun <T, K, V> any_array<T>.associate(
    transform: (T) -> Pair<K, V>
): Map<K, V>

Returns a Map containing key-value pairs provided by transform function applied to elements of the given collection.

fun <T, K, V> Iterable<T>.associate(
    transform: (T) -> Pair<K, V>
): Map<K, V>
Common
JVM
JS
Native
1.0

associateBy

Returns a Map containing the elements from the given array indexed by the key returned from keySelector function applied to each element.

fun <T, K> any_array<T>.associateBy(
    keySelector: (T) -> K
): Map<K, T>

Returns a Map containing the values provided by valueTransform and indexed by keySelector functions applied to elements of the given array.

fun <T, K, V> any_array<T>.associateBy(
    keySelector: (T) -> K,
    valueTransform: (T) -> V
): Map<K, V>

Returns a Map containing the elements from the given collection indexed by the key returned from keySelector function applied to each element.

fun <T, K> Iterable<T>.associateBy(
    keySelector: (T) -> K
): Map<K, T>

Returns a Map containing the values provided by valueTransform and indexed by keySelector functions applied to elements of the given collection.

fun <T, K, V> Iterable<T>.associateBy(
    keySelector: (T) -> K,
    valueTransform: (T) -> V
): Map<K, V>
Common
JVM
JS
Native
1.0

associateByTo

Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function applied to each element of the given array and value is the element itself.

fun <T, K, M : MutableMap<in K, in T>> any_array<T>.associateByTo(
    destination: M,
    keySelector: (T) -> K
): M

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

fun <T, K, V, M : MutableMap<in K, in V>> any_array<T>.associateByTo(
    destination: M,
    keySelector: (T) -> K,
    valueTransform: (T) -> V
): M

Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function applied to each element of the given collection and value is the element itself.

fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(
    destination: M,
    keySelector: (T) -> K
): M

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.

fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(
    destination: M,
    keySelector: (T) -> K,
    valueTransform: (T) -> V
): M
Common
JVM
JS
Native
1.0

associateTo

Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each element of the given array.

fun <T, K, V, M : MutableMap<in K, in V>> any_array<T>.associateTo(
    destination: M,
    transform: (T) -> Pair<K, V>
): M

Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each element of the given collection.

fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(
    destination: M,
    transform: (T) -> Pair<K, V>
): M
Common
JVM
JS
Native
1.3

associateWith

Returns a Map where keys are elements from the given collection and values are produced by the valueSelector function applied to each element.

fun <K, V> Iterable<K>.associateWith(
    valueSelector: (K) -> V
): Map<K, V>
Common
JVM
JS
Native
1.3

associateWithTo

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.

fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(
    destination: M,
    valueSelector: (K) -> V
): M
Common
JVM
JS
Native
1.3

asUByteArray

Returns an array of type UByteArray, which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array.

fun ByteArray.asUByteArray(): UByteArray
Common
JVM
JS
Native
1.3

asUIntArray

Returns an array of type UIntArray, which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array.

fun IntArray.asUIntArray(): UIntArray
Common
JVM
JS
Native
1.3

asULongArray

Returns an array of type ULongArray, which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array.

fun LongArray.asULongArray(): ULongArray
Common
JVM
JS
Native
1.3

asUShortArray

Returns an array of type UShortArray, which is a view of this array where each element is an unsigned reinterpretation of the corresponding element of this array.

fun ShortArray.asUShortArray(): UShortArray
Common
JVM
JS
Native
1.0

average

Returns an average value of elements in the array.

fun Array<out Byte>.average(): Double
fun Array<out Short>.average(): Double
fun Array<out Int>.average(): Double
fun Array<out Long>.average(): Double
fun Array<out Float>.average(): Double
fun Array<out Double>.average(): Double
fun ByteArray.average(): Double
fun ShortArray.average(): Double
fun IntArray.average(): Double
fun LongArray.average(): Double
fun FloatArray.average(): Double
fun DoubleArray.average(): Double

Returns an average value of elements in the collection.

fun Iterable<Byte>.average(): Double
fun Iterable<Short>.average(): Double
fun Iterable<Int>.average(): Double
fun Iterable<Long>.average(): Double
fun Iterable<Float>.average(): Double
fun Iterable<Double>.average(): Double

binarySearch

Common
JVM
JS
Native
1.0

Searches this list or its range for the provided element using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of its elements, otherwise the result is undefined.

fun <T : Comparable<T>> List<T?>.binarySearch(
    element: T?,
    fromIndex: Int = 0,
    toIndex: Int = size
): Int
Common
JVM
JS
Native
1.0

Searches this list or its range for the provided element using the binary search algorithm. The list is expected to be sorted into ascending order according to the specified comparator, otherwise the result is undefined.

fun <T> List<T>.binarySearch(
    element: T,
    comparator: Comparator<in T>,
    fromIndex: Int = 0,
    toIndex: Int = size
): Int
Common
JVM
JS
Native
1.0

Searches this list or its range for an element for which comparison function returns zero using the binary search algorithm. The list is expected to be sorted into ascending order according to the provided comparison, otherwise the result is undefined.

fun <T> List<T>.binarySearch(
    fromIndex: Int = 0,
    toIndex: Int = size,
    comparison: (T) -> Int
): Int
JVM
1.0

Searches the array or the range of the array for the provided element using the binary search algorithm. The array is expected to be sorted according to the specified comparator, otherwise the result is undefined.

fun <T> Array<out T>.binarySearch(
    element: T,
    comparator: Comparator<in T>,
    fromIndex: Int = 0,
    toIndex: Int = size
): Int
JVM
1.0

Searches the array or the range of the array for the provided element using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined.

fun <T> any_array<T>.binarySearch(
    element: T,
    fromIndex: Int = 0,
    toIndex: Int = size
): Int
Common
JVM
JS
Native
1.0

binarySearchBy

Searches this list or its range for an element having the key returned by the specified selector function equal to the provided key value using the binary search algorithm. The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements. otherwise the result is undefined.

fun <T, K : Comparable<K>> List<T>.binarySearchBy(
    key: K?,
    fromIndex: Int = 0,
    toIndex: Int = size,
    selector: (T) -> K?
): Int
Common
JVM
JS
Native
1.2

chunked

Splits this collection into a list of lists each not exceeding the given size.

fun <T> Iterable<T>.chunked(size: Int): List<List<T>>

Splits this collection into several lists each not exceeding the given size and applies the given transform function to an each.

fun <T, R> Iterable<T>.chunked(
    size: Int,
    transform: (List<T>) -> R
): List<R>
Common
JVM
JS
Native
1.0

component1

Returns 1st element from the collection.

operator fun <T> Array<out T>.component1(): T
operator fun ByteArray.component1(): Byte
operator fun ShortArray.component1(): Short
operator fun IntArray.component1(): Int
operator fun LongArray.component1(): Long
operator fun FloatArray.component1(): Float
operator fun DoubleArray.component1(): Double
operator fun BooleanArray.component1(): Boolean
operator fun CharArray.component1(): Char
operator fun <T> List<T>.component1(): T

Returns the key component of the map entry.

operator fun <K, V> Entry<K, V>.component1(): K
Common
JVM
JS
Native
1.0

component2

Returns 2nd element from the collection.

operator fun <T> Array<out T>.component2(): T
operator fun ByteArray.component2(): Byte
operator fun ShortArray.component2(): Short
operator fun IntArray.component2(): Int
operator fun LongArray.component2(): Long
operator fun FloatArray.component2(): Float
operator fun DoubleArray.component2(): Double
operator fun BooleanArray.component2(): Boolean
operator fun CharArray.component2(): Char
operator fun <T> List<T>.component2(): T

Returns the value component of the map entry.

operator fun <K, V> Entry<K, V>.component2(): V
Common
JVM
JS
Native
1.0

component3

Returns 3rd element from the collection.

operator fun <T> Array<out T>.component3(): T
operator fun ByteArray.component3(): Byte
operator fun ShortArray.component3(): Short
operator fun IntArray.component3(): Int
operator fun LongArray.component3(): Long
operator fun FloatArray.component3(): Float
operator fun DoubleArray.component3(): Double
operator fun BooleanArray.component3(): Boolean
operator fun CharArray.component3(): Char
operator fun <T> List<T>.component3(): T
Common
JVM
JS
Native
1.0

component4

Returns 4th element from the collection.

operator fun <T> Array<out T>.component4(): T
operator fun ByteArray.component4(): Byte
operator fun ShortArray.component4(): Short
operator fun IntArray.component4(): Int
operator fun LongArray.component4(): Long
operator fun FloatArray.component4(): Float
operator fun DoubleArray.component4(): Double
operator fun BooleanArray.component4(): Boolean
operator fun CharArray.component4(): Char
operator fun <T> List<T>.component4(): T
Common
JVM
JS
Native
1.0

component5

Returns 5th element from the collection.

operator fun <T> Array<out T>.component5(): T
operator fun ByteArray.component5(): Byte
operator fun ShortArray.component5(): Short
operator fun IntArray.component5(): Int
operator fun LongArray.component5(): Long
operator fun FloatArray.component5(): Float
operator fun DoubleArray.component5(): Double
operator fun BooleanArray.component5(): Boolean
operator fun CharArray.component5(): Char
operator fun <T> List<T>.component5(): T
Common
JVM
JS
Native
1.0

contains

Returns true if element is found in the array.

operator fun <T> any_array<T>.contains(element: T): Boolean

Returns true if element is found in the collection.

operator fun <T> Iterable<T>.contains(element: T): Boolean

Checks if the map contains the given key.

operator fun <K, V> Map<out K, V>.contains(key: K): Boolean
Common
JVM
JS
Native
1.0

containsAll

Checks if all elements in the specified collection are contained in this collection.

fun <T> Collection<T>.containsAll(
    elements: Collection<T>
): Boolean
Common
JVM
JS
Native
1.0

containsKey

Returns true if the map contains the specified key.

fun <K> Map<out K, *>.containsKey(key: K): Boolean
Common
JVM
JS
Native
1.0

containsValue

Returns true if the map maps one or more keys to the specified value.

fun <K, V> Map<K, V>.containsValue(value: V): Boolean
Common
JVM
JS
Native
1.1

contentDeepEquals

Returns true if the two specified arrays are deeply equal to one another, i.e. contain the same number of the same elements in the same order.

infix fun <T> any_array<T>.contentDeepEquals(
    other: Array<out T>
): Boolean
Common
JVM
JS
Native
1.1

contentDeepHashCode

Returns a hash code based on the contents of this array as if it is List. Nested arrays are treated as lists too.

fun <T> any_array<T>.contentDeepHashCode(): Int
Common
JVM
JS
Native
1.1

contentDeepToString

Returns a string representation of the contents of this array as if it is a List. Nested arrays are treated as lists too.

fun <T> any_array<T>.contentDeepToString(): String
Common
JVM
JS
Native
1.1

contentEquals

Returns true if the two specified arrays are structurally equal to one another, i.e. contain the same number of the same elements in the same order.

infix fun UIntArray.contentEquals(other: UIntArray): Boolean
infix fun ULongArray.contentEquals(
    other: ULongArray
): Boolean
infix fun UByteArray.contentEquals(
    other: UByteArray
): Boolean
infix fun UShortArray.contentEquals(
    other: UShortArray
): Boolean
infix fun <T> Array<out T>.contentEquals(
    other: Array<out T>
): Boolean
infix fun ByteArray.contentEquals(other: ByteArray): Boolean
infix fun ShortArray.contentEquals(
    other: ShortArray
): Boolean
infix fun IntArray.contentEquals(other: IntArray): Boolean
infix fun LongArray.contentEquals(other: LongArray): Boolean
infix fun FloatArray.contentEquals(
    other: FloatArray
): Boolean
infix fun DoubleArray.contentEquals(
    other: DoubleArray
): Boolean
infix fun BooleanArray.contentEquals(
    other: BooleanArray
): Boolean
infix fun CharArray.contentEquals(other: CharArray): Boolean
Common
JVM
JS
Native
1.1

contentHashCode

Returns a hash code based on the contents of this array as if it is List.

fun UIntArray.contentHashCode(): Int
fun ULongArray.contentHashCode(): Int
fun UByteArray.contentHashCode(): Int
fun UShortArray.contentHashCode(): Int
fun <T> Array<out T>.contentHashCode(): Int
fun ByteArray.contentHashCode(): Int
fun ShortArray.contentHashCode(): Int
fun IntArray.contentHashCode(): Int
fun LongArray.contentHashCode(): Int
fun FloatArray.contentHashCode(): Int
fun DoubleArray.contentHashCode(): Int
fun BooleanArray.contentHashCode(): Int
fun CharArray.contentHashCode(): Int
Common
JVM
JS
Native
1.1

contentToString

Returns a string representation of the contents of the specified array as if it is List.

fun UIntArray.contentToString(): String
fun ULongArray.contentToString(): String
fun UByteArray.contentToString(): String
fun UShortArray.contentToString(): String
fun <T> Array<out T>.contentToString(): String
fun ByteArray.contentToString(): String
fun ShortArray.contentToString(): String
fun IntArray.contentToString(): String
fun LongArray.contentToString(): String
fun FloatArray.contentToString(): String
fun DoubleArray.contentToString(): String
fun BooleanArray.contentToString(): String
fun CharArray.contentToString(): String

copyInto

Copies this array or its subrange into the destination array and returns that array.

Common
JVM
JS
Native
1.3
fun UIntArray.copyInto(
    destination: UIntArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): UIntArray
Common
JVM
JS
Native
1.3
fun ULongArray.copyInto(
    destination: ULongArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): ULongArray
Common
JVM
JS
Native
1.3
fun UByteArray.copyInto(
    destination: UByteArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): UByteArray
Common
JVM
JS
Native
1.3
fun UShortArray.copyInto(
    destination: UShortArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): UShortArray
Common
JVM
JS
1.3
fun <T> Array<out T>.copyInto(
    destination: Array<T>,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): Array<T>
Native
1.3
fun <T> Array<out T>.copyInto(
    destination: Array<T>,
    destinationOffset: Int,
    startIndex: Int,
    endIndex: Int
): Array<T>
Common
JVM
JS
1.3
fun ByteArray.copyInto(
    destination: ByteArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): ByteArray
Native
1.3
fun ByteArray.copyInto(
    destination: ByteArray,
    destinationOffset: Int,
    startIndex: Int,
    endIndex: Int
): ByteArray
Common
JVM
JS
1.3
fun ShortArray.copyInto(
    destination: ShortArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): ShortArray
Native
1.3
fun ShortArray.copyInto(
    destination: ShortArray,
    destinationOffset: Int,
    startIndex: Int,
    endIndex: Int
): ShortArray
Common
JVM
JS
1.3
fun IntArray.copyInto(
    destination: IntArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): IntArray
Native
1.3
fun IntArray.copyInto(
    destination: IntArray,
    destinationOffset: Int,
    startIndex: Int,
    endIndex: Int
): IntArray
Common
JVM
JS
1.3
fun LongArray.copyInto(
    destination: LongArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): LongArray
Native
1.3
fun LongArray.copyInto(
    destination: LongArray,
    destinationOffset: Int,
    startIndex: Int,
    endIndex: Int
): LongArray
Common
JVM
JS
1.3
fun FloatArray.copyInto(
    destination: FloatArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): FloatArray
Native
1.3
fun FloatArray.copyInto(
    destination: FloatArray,
    destinationOffset: Int,
    startIndex: Int,
    endIndex: Int
): FloatArray
Common
JVM
JS
1.3
fun DoubleArray.copyInto(
    destination: DoubleArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): DoubleArray
Native
1.3
fun DoubleArray.copyInto(
    destination: DoubleArray,
    destinationOffset: Int,
    startIndex: Int,
    endIndex: Int
): DoubleArray
Common
JVM
JS
1.3
fun BooleanArray.copyInto(
    destination: BooleanArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): BooleanArray
Native
1.3
fun BooleanArray.copyInto(
    destination: BooleanArray,
    destinationOffset: Int,
    startIndex: Int,
    endIndex: Int
): BooleanArray
Common
JVM
JS
1.3
fun CharArray.copyInto(
    destination: CharArray,
    destinationOffset: Int = 0,
    startIndex: Int = 0,
    endIndex: Int = size
): CharArray
Native
1.3
fun CharArray.copyInto(
    destination: CharArray,
    destinationOffset: Int,
    startIndex: Int,
    endIndex: Int
): CharArray

copyOf

Returns new array which is a copy of the original array.

Common
JVM
JS
Native
1.3
fun UIntArray.copyOf(): UIntArray
Common
JVM
JS
Native
1.3
fun ULongArray.copyOf(): ULongArray
Common
JVM
JS
Native
1.3
fun UByteArray.copyOf(): UByteArray
Common
JVM
JS
Native
1.3
fun UShortArray.copyOf(): UShortArray
Common
JVM
Native
1.0
fun <T> Array<T>.copyOf(): Array<T>
JS
1.1
fun <T> Array<out T>.copyOf(): Array<T>
Common
JVM
JS
Native
1.0
fun ByteArray.copyOf(): ByteArray
Common
JVM
JS
Native
1.0
fun ShortArray.copyOf(): ShortArray
Common
JVM
JS
Native
1.0
fun IntArray.copyOf(): IntArray
Common
JVM
JS
Native
1.0
fun LongArray.copyOf(): LongArray
Common
JVM
JS
Native
1.0
fun FloatArray.copyOf(): FloatArray
Common
JVM
JS
Native
1.0
fun DoubleArray.copyOf(): DoubleArray
Common
JVM
JS
Native
1.0
Common
JVM
JS
Native
1.0
fun CharArray.copyOf(): CharArray

Returns new array which is a copy of the original array, resized to the given newSize. The copy is either truncated or padded at the end with zero values if necessary.

Common
JVM
JS
Native
1.3
fun UIntArray.copyOf(newSize: Int): UIntArray
Common
JVM
JS
Native
1.3
fun ULongArray.copyOf(newSize: Int): ULongArray
Common
JVM
JS
Native
1.3
fun UByteArray.copyOf(newSize: Int): UByteArray
Common
JVM
JS
Native
1.3
fun UShortArray.copyOf(newSize: Int): UShortArray
Common
JVM
JS
Native
1.0
fun ByteArray.copyOf(newSize: Int): ByteArray
Common
JVM
JS
Native
1.0
fun ShortArray.copyOf(newSize: Int): ShortArray
Common
JVM
JS
Native
1.0
fun IntArray.copyOf(newSize: Int): IntArray
Common
JVM
JS
Native
1.0
fun LongArray.copyOf(newSize: Int): LongArray
Common
JVM
JS
Native
1.0
fun FloatArray.copyOf(newSize: Int): FloatArray
Common
JVM
JS
Native
1.0
fun DoubleArray.copyOf(newSize: Int): DoubleArray

Returns new array which is a copy of the original array, resized to the given newSize. The copy is either truncated or padded at the end with false values if necessary.

Common
JVM
JS
Native
1.0
fun BooleanArray.copyOf(newSize: Int): BooleanArray

Returns new array which is a copy of the original array, resized to the given newSize. The copy is either truncated or padded at the end with null char (\u0000) values if necessary.

Common
JVM
JS
Native
1.0
fun CharArray.copyOf(newSize: Int): CharArray

Returns new array which is a copy of the original array, resized to the given newSize. The copy is either truncated or padded at the end with null values if necessary.

Common
JVM
JS
Native
1.0
fun <T> any_array<T>.copyOf(newSize: Int): Array<T?>

copyOfRange

Returns a new array which is a copy of the specified range of the original array.

Common
JVM
JS
Native
1.3
fun UIntArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): UIntArray
Common
JVM
JS
Native
1.3
fun ULongArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): ULongArray
Common
JVM
JS
Native
1.3
fun UByteArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): UByteArray
Common
JVM
JS
Native
1.3
fun UShortArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): UShortArray
Common
JVM
Native
1.0
fun <T> Array<T>.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): Array<T>
JS
1.1
fun <T> Array<out T>.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): Array<T>
Common
JVM
JS
Native
1.0
fun ByteArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): ByteArray
Common
JVM
JS
Native
1.0
fun ShortArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): ShortArray
Common
JVM
JS
Native
1.0
fun IntArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): IntArray
Common
JVM
JS
Native
1.0
fun LongArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): LongArray
Common
JVM
JS
Native
1.0
fun FloatArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): FloatArray
Common
JVM
JS
Native
1.0
fun DoubleArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): DoubleArray
Common
JVM
JS
Native
1.0
fun BooleanArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): BooleanArray
Common
JVM
JS
Native
1.0
fun CharArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): CharArray
Native
1.3

copyRange

Copies a range of array elements at a specified fromIndex (inclusive) to toIndex (exclusive) range of indices to another part of this array starting at destinationIndex.

fun <E> Array<E>.copyRange(
    fromIndex: Int,
    toIndex: Int,
    destinationIndex: Int = 0)
Common
JVM
JS
Native
1.0

count

Returns the number of elements in this array.

fun <T> any_array<T>.count(): Int

Returns the number of elements matching the given predicate.

fun <T> Array<out T>.count(predicate: (T) -> Boolean): Int
fun ByteArray.count(predicate: (Byte) -> Boolean): Int
fun ShortArray.count(predicate: (Short) -> Boolean): Int
fun IntArray.count(predicate: (Int) -> Boolean): Int
fun LongArray.count(predicate: (Long) -> Boolean): Int
fun FloatArray.count(predicate: (Float) -> Boolean): Int
fun DoubleArray.count(predicate: (Double) -> Boolean): Int
fun BooleanArray.count(predicate: (Boolean) -> Boolean): Int
fun CharArray.count(predicate: (Char) -> Boolean): Int
fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int

Returns the number of elements in this collection.

fun <T> Iterable<T>.count(): Int
fun <T> Collection<T>.count(): Int

Returns the number of entries in this map.

fun <K, V> Map<out K, V>.count(): Int

Returns the number of entries matching the given predicate.

fun <K, V> Map<out K, V>.count(
    predicate: (Entry<K, V>) -> Boolean
): Int
Common
JVM
JS
Native
1.0

distinct

Returns a list containing only distinct elements from the given array.

fun <T> any_array<T>.distinct(): List<T>

Returns a list containing only distinct elements from the given collection.

fun <T> Iterable<T>.distinct(): List<T>
Common
JVM
JS
Native
1.0

distinctBy

Returns a list containing only elements from the given array having distinct keys returned by the given selector function.

fun <T, K> any_array<T>.distinctBy(
    selector: (T) -> K
): List<T>

Returns a list containing only elements from the given collection having distinct keys returned by the given selector function.

fun <T, K> Iterable<T>.distinctBy(
    selector: (T) -> K
): List<T>
Common
JVM
JS
Native
1.0

drop

Returns a list containing all elements except first n elements.

fun <T> Array<out T>.drop(n: Int): List<T>
fun ByteArray.drop(n: Int): List<Byte>
fun ShortArray.drop(n: Int): List<Short>
fun IntArray.drop(n: Int): List<Int>
fun LongArray.drop(n: Int): List<Long>
fun FloatArray.drop(n: Int): List<Float>
fun DoubleArray.drop(n: Int): List<Double>
fun BooleanArray.drop(n: Int): List<Boolean>
fun CharArray.drop(n: Int): List<Char>
fun <T> Iterable<T>.drop(n: Int): List<T>
Common
JVM
JS
Native
1.0

dropLast

Returns a list containing all elements except last n elements.

fun <T> Array<out T>.dropLast(n: Int): List<T>
fun ByteArray.dropLast(n: Int): List<Byte>
fun ShortArray.dropLast(n: Int): List<Short>
fun IntArray.dropLast(n: Int): List<Int>
fun LongArray.dropLast(n: Int): List<Long>
fun FloatArray.dropLast(n: Int): List<Float>
fun DoubleArray.dropLast(n: Int): List<Double>
fun BooleanArray.dropLast(n: Int): List<Boolean>
fun CharArray.dropLast(n: Int): List<Char>
fun <T> List<T>.dropLast(n: Int): List<T>
Common
JVM
JS
Native
1.0

dropLastWhile

Returns a list containing all elements except last elements that satisfy the given predicate.

fun <T> Array<out T>.dropLastWhile(
    predicate: (T) -> Boolean
): List<T>
fun ByteArray.dropLastWhile(
    predicate: (Byte) -> Boolean
): List<Byte>
fun ShortArray.dropLastWhile(
    predicate: (Short) -> Boolean
): List<Short>
fun IntArray.dropLastWhile(
    predicate: (Int) -> Boolean
): List<Int>
fun LongArray.dropLastWhile(
    predicate: (Long) -> Boolean
): List<Long>
fun FloatArray.dropLastWhile(
    predicate: (Float) -> Boolean
): List<Float>
fun DoubleArray.dropLastWhile(
    predicate: (Double) -> Boolean
): List<Double>
fun BooleanArray.dropLastWhile(
    predicate: (Boolean) -> Boolean
): List<Boolean>
fun CharArray.dropLastWhile(
    predicate: (Char) -> Boolean
): List<Char>
fun <T> List<T>.dropLastWhile(
    predicate: (T) -> Boolean
): List<T>
Common
JVM
JS
Native
1.0

dropWhile

Returns a list containing all elements except first elements that satisfy the given predicate.

fun <T> Array<out T>.dropWhile(
    predicate: (T) -> Boolean
): List<T>
fun ByteArray.dropWhile(
    predicate: (Byte) -> Boolean
): List<Byte>
fun ShortArray.dropWhile(
    predicate: (Short) -> Boolean
): List<Short>
fun IntArray.dropWhile(
    predicate: (Int) -> Boolean
): List<Int>
fun LongArray.dropWhile(
    predicate: (Long) -> Boolean
): List<Long>
fun FloatArray.dropWhile(
    predicate: (Float) -> Boolean
): List<Float>
fun DoubleArray.dropWhile(
    predicate: (Double) -> Boolean
): List<Double>
fun BooleanArray.dropWhile(
    predicate: (Boolean) -> Boolean
): List<Boolean>
fun CharArray.dropWhile(
    predicate: (Char) -> Boolean
): List<Char>
fun <T> Iterable<T>.dropWhile(
    predicate: (T) -> Boolean
): List<T>
Common
JVM
JS
Native
1.0

eachCount

Groups elements from the Grouping source by key and counts elements in each group.

fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int>
Common
JVM
JS
Native
1.1

eachCountTo

Groups elements from the Grouping source by key and counts elements in each group to the given destination map.

fun <T, K, M : MutableMap<in K, Int>> Grouping<T, K>.eachCountTo(
    destination: M
): M
Common
JVM
JS
Native
1.0

elementAt

Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.

fun <T> any_array<T>.elementAt(index: Int): T

Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this collection.

fun <T> Iterable<T>.elementAt(index: Int): T

Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this list.

fun <T> List<T>.elementAt(index: Int): T
Common
JVM
JS
Native
1.0

elementAtOrElse

Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this array.

fun <T> any_array<T>.elementAtOrElse(
    index: Int,
    defaultValue: (Int) -> T
): T

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.

fun <T> Iterable<T>.elementAtOrElse(
    index: Int,
    defaultValue: (Int) -> T
): T

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.

fun <T> List<T>.elementAtOrElse(
    index: Int,
    defaultValue: (Int) -> T
): T
Common
JVM
JS
Native
1.0

elementAtOrNull

Returns an element at the given index or null if the index is out of bounds of this array.

fun <T> any_array<T>.elementAtOrNull(index: Int): T?

Returns an element at the given index or null if the index is out of bounds of this collection.

fun <T> Iterable<T>.elementAtOrNull(index: Int): T?

Returns an element at the given index or null if the index is out of bounds of this list.

fun <T> List<T>.elementAtOrNull(index: Int): T?
Common
JVM
JS
Native
1.0

emptyList

Returns an empty read-only list. The returned list is serializable (JVM).

fun <T> emptyList(): List<T>
Common
JVM
JS
Native
1.0

emptyMap

Returns an empty read-only map of specified type.

fun <K, V> emptyMap(): Map<K, V>
Common
JVM
JS
Native
1.0

emptySet

Returns an empty read-only set. The returned set is serializable (JVM).

fun <T> emptySet(): Set<T>

fill

JVM
1.0

Fills original array with the provided value.

fun <T> any_array<T>.fill(
    element: T,
    fromIndex: Int = 0,
    toIndex: Int = size)
Common
JVM
JS
Native
1.2

Fills the list with the provided value.

fun <T> MutableList<T>.fill(value: T)
Common
JVM
JS
Native
1.0

filter

Returns a list containing only elements matching the given predicate.

fun <T> Array<out T>.filter(
    predicate: (T) -> Boolean
): List<T>
fun ByteArray.filter(
    predicate: (Byte) -> Boolean
): List<Byte>
fun ShortArray.filter(
    predicate: (Short) -> Boolean
): List<Short>
fun IntArray.filter(predicate: (Int) -> Boolean): List<Int>
fun LongArray.filter(
    predicate: (Long) -> Boolean
): List<Long>
fun FloatArray.filter(
    predicate: (Float) -> Boolean
): List<Float>
fun DoubleArray.filter(
    predicate: (Double) -> Boolean
): List<Double>
fun BooleanArray.filter(
    predicate: (Boolean) -> Boolean
): List<Boolean>
fun CharArray.filter(
    predicate: (Char) -> Boolean
): List<Char>
fun <T> Iterable<T>.filter(
    predicate: (T) -> Boolean
): List<T>

Returns a new map containing all key-value pairs matching the given predicate.

fun <K, V> Map<out K, V>.filter(
    predicate: (Entry<K, V>) -> Boolean
): Map<K, V>
Common
JVM
JS
Native
1.0

filterIndexed

Returns a list containing only elements matching the given predicate.

fun <T> Array<out T>.filterIndexed(
    predicate: (index: Int, T) -> Boolean
): List<T>
fun ByteArray.filterIndexed(
    predicate: (index: Int, Byte) -> Boolean
): List<Byte>
fun ShortArray.filterIndexed(
    predicate: (index: Int, Short) -> Boolean
): List<Short>
fun IntArray.filterIndexed(
    predicate: (index: Int, Int) -> Boolean
): List<Int>
fun LongArray.filterIndexed(
    predicate: (index: Int, Long) -> Boolean
): List<Long>
fun FloatArray.filterIndexed(
    predicate: (index: Int, Float) -> Boolean
): List<Float>
fun DoubleArray.filterIndexed(
    predicate: (index: Int, Double) -> Boolean
): List<Double>
fun BooleanArray.filterIndexed(
    predicate: (index: Int, Boolean) -> Boolean
): List<Boolean>
fun CharArray.filterIndexed(
    predicate: (index: Int, Char) -> Boolean
): List<Char>
fun <T> Iterable<T>.filterIndexed(
    predicate: (index: Int, T) -> Boolean
): List<T>
Common
JVM
JS
Native
1.0

filterIndexedTo

Appends all elements matching the given predicate to the given destination.

fun <T, C : MutableCollection<in T>> Array<out T>.filterIndexedTo(
    destination: C,
    predicate: (index: Int, T) -> Boolean
): C
fun <C : MutableCollection<in Byte>> ByteArray.filterIndexedTo(
    destination: C,
    predicate: (index: Int, Byte) -> Boolean
): C
fun <C : MutableCollection<in Short>> ShortArray.filterIndexedTo(
    destination: C,
    predicate: (index: Int, Short) -> Boolean
): C
fun <C : MutableCollection<in Int>> IntArray.filterIndexedTo(
    destination: C,
    predicate: (index: Int, Int) -> Boolean
): C
fun <C : MutableCollection<in Long>> LongArray.filterIndexedTo(
    destination: C,
    predicate: (index: Int, Long) -> Boolean
): C
fun <C : MutableCollection<in Float>> FloatArray.filterIndexedTo(
    destination: C,
    predicate: (index: Int, Float) -> Boolean
): C
fun <C : MutableCollection<in Double>> DoubleArray.filterIndexedTo(
    destination: C,
    predicate: (index: Int, Double) -> Boolean
): C
fun <C : MutableCollection<in Boolean>> BooleanArray.filterIndexedTo(
    destination: C,
    predicate: (index: Int, Boolean) -> Boolean
): C
fun <C : MutableCollection<in Char>> CharArray.filterIndexedTo(
    destination: C,
    predicate: (index: Int, Char) -> Boolean
): C
fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(
    destination: C,
    predicate: (index: Int, T) -> Boolean
): C

filterIsInstance

Common
JVM
JS
Native
1.0

Returns a list containing all elements that are instances of specified type parameter R.

fun <R> Array<*>.filterIsInstance(): List<R>
fun <R> Iterable<*>.filterIsInstance(): List<R>
JVM
1.0

Returns a list containing all elements that are instances of specified class.

fun <R> Array<*>.filterIsInstance(klass: Class<R>): List<R>
fun <R> Iterable<*>.filterIsInstance(
    klass: Class<R>
): List<R>

filterIsInstanceTo

Common
JVM
JS
Native
1.0

Appends all elements that are instances of specified type parameter R to the given destination.

fun <R, C : MutableCollection<in R>> Array<*>.filterIsInstanceTo(
    destination: C
): C
fun <R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(
    destination: C
): C
JVM
1.0

Appends all elements that are instances of specified class to the given destination.

fun <C : MutableCollection<in R>, R> Array<*>.filterIsInstanceTo(
    destination: C,
    klass: Class<R>
): C
fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(
    destination: C,
    klass: Class<R>
): C
Common
JVM
JS
Native
1.0

filterKeys

Returns a map containing all key-value pairs with keys matching the given predicate.

fun <K, V> Map<out K, V>.filterKeys(
    predicate: (K) -> Boolean
): Map<K, V>
Common
JVM
JS
Native
1.0

filterNot

Returns a list containing all elements not matching the given predicate.

fun <T> Array<out T>.filterNot(
    predicate: (T) -> Boolean
): List<T>
fun ByteArray.filterNot(
    predicate: (Byte) -> Boolean
): List<Byte>
fun ShortArray.filterNot(
    predicate: (Short) -> Boolean
): List<Short>
fun IntArray.filterNot(
    predicate: (Int) -> Boolean
): List<Int>
fun LongArray.filterNot(
    predicate: (Long) -> Boolean
): List<Long>
fun FloatArray.filterNot(
    predicate: (Float) -> Boolean
): List<Float>
fun DoubleArray.filterNot(
    predicate: (Double) -> Boolean
): List<Double>
fun BooleanArray.filterNot(
    predicate: (Boolean) -> Boolean
): List<Boolean>
fun CharArray.filterNot(
    predicate: (Char) -> Boolean
): List<Char>
fun <T> Iterable<T>.filterNot(
    predicate: (T) -> Boolean
): List<T>

Returns a new map containing all key-value pairs not matching the given predicate.

fun <K, V> Map<out K, V>.filterNot(
    predicate: (Entry<K, V>) -> Boolean
): Map<K, V>
Common
JVM
JS
Native
1.0

filterNotNull

Returns a list containing all elements that are not null.

fun <T : Any> Array<out T?>.filterNotNull(): List<T>
fun <T : Any> Iterable<T?>.filterNotNull(): List<T>
Common
JVM
JS
Native
1.0

filterNotNullTo

Appends all elements that are not null to the given destination.

fun <C : MutableCollection<in T>, T : Any> Array<out T?>.filterNotNullTo(
    destination: C
): C
fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(
    destination: C
): C
Common
JVM
JS
Native
1.0

filterNotTo

Appends all elements not matching the given predicate to the given destination.

fun <T, C : MutableCollection<in T>> Array<out T>.filterNotTo(
    destination: C,
    predicate: (T) -> Boolean
): C
fun <C : MutableCollection<in Byte>> ByteArray.filterNotTo(
    destination: C,
    predicate: (Byte) -> Boolean
): C
fun <C : MutableCollection<in Short>> ShortArray.filterNotTo(
    destination: C,
    predicate: (Short) -> Boolean
): C
fun <C : MutableCollection<in Int>> IntArray.filterNotTo(
    destination: C,
    predicate: (Int) -> Boolean
): C
fun <C : MutableCollection<in Long>> LongArray.filterNotTo(
    destination: C,
    predicate: (Long) -> Boolean
): C
fun <C : MutableCollection<in Float>> FloatArray.filterNotTo(
    destination: C,
    predicate: (Float) -> Boolean
): C
fun <C : MutableCollection<in Double>> DoubleArray.filterNotTo(
    destination: C,
    predicate: (Double) -> Boolean
): C
fun <C : MutableCollection<in Boolean>> BooleanArray.filterNotTo(
    destination: C,
    predicate: (Boolean) -> Boolean
): C
fun <C : MutableCollection<in Char>> CharArray.filterNotTo(
    destination: C,
    predicate: (Char) -> Boolean
): C
fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(
    destination: C,
    predicate: (T) -> Boolean
): C

Appends all entries not matching the given predicate into the given destination.

fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(
    destination: M,
    predicate: (Entry<K, V>) -> Boolean
): M
Common
JVM
JS
Native
1.0

filterTo

Appends all elements matching the given predicate to the given destination.

fun <T, C : MutableCollection<in T>> Array<out T>.filterTo(
    destination: C,
    predicate: (T) -> Boolean
): C
fun <C : MutableCollection<in Byte>> ByteArray.filterTo(
    destination: C,
    predicate: (Byte) -> Boolean
): C
fun <C : MutableCollection<in Short>> ShortArray.filterTo(
    destination: C,
    predicate: (Short) -> Boolean
): C
fun <C : MutableCollection<in Int>> IntArray.filterTo(
    destination: C,
    predicate: (Int) -> Boolean
): C
fun <C : MutableCollection<in Long>> LongArray.filterTo(
    destination: C,
    predicate: (Long) -> Boolean
): C
fun <C : MutableCollection<in Float>> FloatArray.filterTo(
    destination: C,
    predicate: (Float) -> Boolean
): C
fun <C : MutableCollection<in Double>> DoubleArray.filterTo(
    destination: C,
    predicate: (Double) -> Boolean
): C
fun <C : MutableCollection<in Boolean>> BooleanArray.filterTo(
    destination: C,
    predicate: (Boolean) -> Boolean
): C
fun <C : MutableCollection<in Char>> CharArray.filterTo(
    destination: C,
    predicate: (Char) -> Boolean
): C
fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(
    destination: C,
    predicate: (T) -> Boolean
): C

Appends all entries matching the given predicate into the mutable map given as destination parameter.

fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(
    destination: M,
    predicate: (Entry<K, V>) -> Boolean
): M
Common
JVM
JS
Native
1.0

filterValues

Returns a map containing all key-value pairs with values matching the given predicate.

fun <K, V> Map<out K, V>.filterValues(
    predicate: (V) -> Boolean
): Map<K, V>
Common
JVM
JS
Native
1.0

find

Returns the first element matching the given predicate, or null if no such element was found.

fun <T> Array<out T>.find(predicate: (T) -> Boolean): T?
fun ByteArray.find(predicate: (Byte) -> Boolean): Byte?
fun ShortArray.find(predicate: (Short) -> Boolean): Short?
fun IntArray.find(predicate: (Int) -> Boolean): Int?
fun LongArray.find(predicate: (Long) -> Boolean): Long?
fun FloatArray.find(predicate: (Float) -> Boolean): Float?
fun DoubleArray.find(predicate: (Double) -> Boolean): Double?
fun BooleanArray.find(
    predicate: (Boolean) -> Boolean
): Boolean?
fun CharArray.find(predicate: (Char) -> Boolean): Char?
fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T?
Common
JVM
JS
Native
1.0

findLast

Returns the last element matching the given predicate, or null if no such element was found.

fun <T> Array<out T>.findLast(predicate: (T) -> Boolean): T?
fun ByteArray.findLast(predicate: (Byte) -> Boolean): Byte?
fun ShortArray.findLast(
    predicate: (Short) -> Boolean
): Short?
fun IntArray.findLast(predicate: (Int) -> Boolean): Int?
fun LongArray.findLast(predicate: (Long) -> Boolean): Long?
fun FloatArray.findLast(
    predicate: (Float) -> Boolean
): Float?
fun DoubleArray.findLast(
    predicate: (Double) -> Boolean
): Double?
fun BooleanArray.findLast(
    predicate: (Boolean) -> Boolean
): Boolean?
fun CharArray.findLast(predicate: (Char) -> Boolean): Char?
fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T?
fun <T> List<T>.findLast(predicate: (T) -> Boolean): T?
Common
JVM
JS
Native
1.0

first

Returns first element.

fun <T> Array<out T>.first(): T
fun ByteArray.first(): Byte
fun ShortArray.first(): Short
fun IntArray.first(): Int
fun LongArray.first(): Long
fun FloatArray.first(): Float
fun DoubleArray.first(): Double
fun BooleanArray.first(): Boolean
fun CharArray.first(): Char
fun <T> Iterable<T>.first(): T
fun <T> List<T>.first(): T

Returns the first element matching the given predicate.

fun <T> Array<out T>.first(predicate: (T) -> Boolean): T
fun ByteArray.first(predicate: (Byte) -> Boolean): Byte
fun ShortArray.first(predicate: (Short) -> Boolean): Short
fun IntArray.first(predicate: (Int) -> Boolean): Int
fun LongArray.first(predicate: (Long) -> Boolean): Long
fun FloatArray.first(predicate: (Float) -> Boolean): Float
fun DoubleArray.first(predicate: (Double) -> Boolean): Double
fun BooleanArray.first(
    predicate: (Boolean) -> Boolean
): Boolean
fun CharArray.first(predicate: (Char) -> Boolean): Char
fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T
Common
JVM
JS
Native
1.0

firstOrNull

Returns the first element, or null if the array is empty.

fun <T> any_array<T>.firstOrNull(): T?

Returns the first element matching the given predicate, or null if element was not found.

fun <T> Array<out T>.firstOrNull(
    predicate: (T) -> Boolean
): T?
fun ByteArray.firstOrNull(
    predicate: (Byte) -> Boolean
): Byte?
fun ShortArray.firstOrNull(
    predicate: (Short) -> Boolean
): Short?
fun IntArray.firstOrNull(predicate: (Int) -> Boolean): Int?
fun LongArray.firstOrNull(
    predicate: (Long) -> Boolean
): Long?
fun FloatArray.firstOrNull(
    predicate: (Float) -> Boolean
): Float?
fun DoubleArray.firstOrNull(
    predicate: (Double) -> Boolean
): Double?
fun BooleanArray.firstOrNull(
    predicate: (Boolean) -> Boolean
): Boolean?
fun CharArray.firstOrNull(
    predicate: (Char) -> Boolean
): Char?
fun <T> Iterable<T>.firstOrNull(
    predicate: (T) -> Boolean
): T?

Returns the first element, or null if the collection is empty.

fun <T> Iterable<T>.firstOrNull(): T?

Returns the first element, or null if the list is empty.

fun <T> List<T>.firstOrNull(): T?
Common
JVM
JS
Native
1.0

flatMap

Returns a single list of all elements yielded from results of transform function being invoked on each element of original array.

fun <T, R> any_array<T>.flatMap(
    transform: (T) -> Iterable<R>
): List<R>

Returns a single list of all elements yielded from results of transform function being invoked on each element of original collection.

fun <T, R> Iterable<T>.flatMap(
    transform: (T) -> Iterable<R>
): List<R>

Returns a single list of all elements yielded from results of transform function being invoked on each entry of original map.

fun <K, V, R> Map<out K, V>.flatMap(
    transform: (Entry<K, V>) -> Iterable<R>
): List<R>
Common
JVM
JS
Native
1.0

flatMapTo

Appends all elements yielded from results of transform function being invoked on each element of original array, to the given destination.

fun <T, R, C : MutableCollection<in R>> any_array<T>.flatMapTo(
    destination: C,
    transform: (T) -> Iterable<R>
): C

Appends all elements yielded from results of transform function being invoked on each element of original collection, to the given destination.

fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(
    destination: C,
    transform: (T) -> Iterable<R>
): C

Appends all elements yielded from results of transform function being invoked on each entry of original map, to the given destination.

fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(
    destination: C,
    transform: (Entry<K, V>) -> Iterable<R>
): C
Common
JVM
JS
Native
1.0

flatten

Returns a single list of all elements from all arrays in the given array.

fun <T> Array<out Array<out T>>.flatten(): List<T>

Returns a single list of all elements from all collections in the given collection.

fun <T> Iterable<Iterable<T>>.flatten(): List<T>
Common
JVM
JS
Native
1.0

fold

Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each element.

fun <T, R> Array<out T>.fold(
    initial: R,
    operation: (acc: R, T) -> R
): R
fun <R> ByteArray.fold(
    initial: R,
    operation: (acc: R, Byte) -> R
): R
fun <R> ShortArray.fold(
    initial: R,
    operation: (acc: R, Short) -> R
): R
fun <R> IntArray.fold(
    initial: R,
    operation: (acc: R, Int) -> R
): R
fun <R> LongArray.fold(
    initial: R,
    operation: (acc: R, Long) -> R
): R
fun <R> FloatArray.fold(
    initial: R,
    operation: (acc: R, Float) -> R
): R
fun <R> DoubleArray.fold(
    initial: R,
    operation: (acc: R, Double) -> R
): R
fun <R> BooleanArray.fold(
    initial: R,
    operation: (acc: R, Boolean) -> R
): R
fun <R> CharArray.fold(
    initial: R,
    operation: (acc: R, Char) -> R
): R
fun <T, R> Iterable<T>.fold(
    initial: R,
    operation: (acc: R, T) -> R
): R

Groups elements from the Grouping source by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is provided by initialValueSelector function.

fun <T, K, R> Grouping<T, K>.fold(
    initialValueSelector: (key: K, element: T) -> R,
    operation: (key: K, accumulator: R, element: T) -> R
): Map<K, R>

Groups elements from the Grouping source by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in a new map. An initial value of accumulator is the same initialValue for each group.

fun <T, K, R> Grouping<T, K>.fold(
    initialValue: R,
    operation: (accumulator: R, element: T) -> R
): Map<K, R>
Common
JVM
JS
Native
1.0

foldIndexed

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

fun <T, R> any_array<T>.foldIndexed(
    initial: R,
    operation: (index: Int, acc: R, T) -> R
): R

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.

fun <T, R> Iterable<T>.foldIndexed(
    initial: R,
    operation: (index: Int, acc: R, T) -> R
): R
Common
JVM
JS
Native
1.0

foldRight

Accumulates value starting with initial value and applying operation from right to left to each element and current accumulator value.

fun <T, R> Array<out T>.foldRight(
    initial: R,
    operation: (T, acc: R) -> R
): R
fun <R> ByteArray.foldRight(
    initial: R,
    operation: (Byte, acc: R) -> R
): R
fun <R> ShortArray.foldRight(
    initial: R,
    operation: (Short, acc: R) -> R
): R
fun <R> IntArray.foldRight(
    initial: R,
    operation: (Int, acc: R) -> R
): R
fun <R> LongArray.foldRight(
    initial: R,
    operation: (Long, acc: R) -> R
): R
fun <R> FloatArray.foldRight(
    initial: R,
    operation: (Float, acc: R) -> R
): R
fun <R> DoubleArray.foldRight(
    initial: R,
    operation: (Double, acc: R) -> R
): R
fun <R> BooleanArray.foldRight(
    initial: R,
    operation: (Boolean, acc: R) -> R
): R
fun <R> CharArray.foldRight(
    initial: R,
    operation: (Char, acc: R) -> R
): R
fun <T, R> List<T>.foldRight(
    initial: R,
    operation: (T, acc: R) -> R
): R
Common
JVM
JS
Native
1.0

foldRightIndexed

Accumulates value starting with initial value and applying operation from right to left to each element with its index in the original array and current accumulator value.

fun <T, R> any_array<T>.foldRightIndexed(
    initial: R,
    operation: (index: Int, T, acc: R) -> R
): R

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.

fun <T, R> List<T>.foldRightIndexed(
    initial: R,
    operation: (index: Int, T, acc: R) -> R
): R
Common
JVM
JS
Native
1.1

foldTo

Groups elements from the Grouping source by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given destination map. An initial value of accumulator is provided by initialValueSelector function.

fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(
    destination: M,
    initialValueSelector: (key: K, element: T) -> R,
    operation: (key: K, accumulator: R, element: T) -> R
): M

Groups elements from the Grouping source by key and applies operation to the elements of each group sequentially, passing the previously accumulated value and the current element as arguments, and stores the results in the given destination map. An initial value of accumulator is the same initialValue for each group.

fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(
    destination: M,
    initialValue: R,
    operation: (accumulator: R, element: T) -> R
): M
Common
JVM
JS
Native
1.0

forEach

Performs the given action on each element.

fun <T> Array<out T>.forEach(action: (T) -> Unit)
fun ByteArray.forEach(action: (Byte) -> Unit)
fun ShortArray.forEach(action: (Short) -> Unit)
fun IntArray.forEach(action: (Int) -> Unit)
fun LongArray.forEach(action: (Long) -> Unit)
fun FloatArray.forEach(action: (Float) -> Unit)
fun DoubleArray.forEach(action: (Double) -> Unit)
fun BooleanArray.forEach(action: (Boolean) -> Unit)
fun CharArray.forEach(action: (Char) -> Unit)
fun <T> Iterable<T>.forEach(action: (T) -> Unit)

Performs the given action on each entry.

fun <K, V> Map<out K, V>.forEach(
    action: (Entry<K, V>) -> Unit)

Performs the given operation on each element of this Iterator.

fun <T> Iterator<T>.forEach(operation: (T) -> Unit)
Common
JVM
JS
Native
1.0

forEachIndexed

Performs the given action on each element, providing sequential index with the element.

fun <T> Array<out T>.forEachIndexed(
    action: (index: Int, T) -> Unit)
fun ByteArray.forEachIndexed(
    action: (index: Int, Byte) -> Unit)
fun ShortArray.forEachIndexed(
    action: (index: Int, Short) -> Unit)
fun IntArray.forEachIndexed(
    action: (index: Int, Int) -> Unit)
fun LongArray.forEachIndexed(
    action: (index: Int, Long) -> Unit)
fun FloatArray.forEachIndexed(
    action: (index: Int, Float) -> Unit)
fun DoubleArray.forEachIndexed(
    action: (index: Int, Double) -> Unit)
fun BooleanArray.forEachIndexed(
    action: (index: Int, Boolean) -> Unit)
fun CharArray.forEachIndexed(
    action: (index: Int, Char) -> Unit)
fun <T> Iterable<T>.forEachIndexed(
    action: (index: Int, T) -> Unit)
Common
JVM
JS
Native
1.0

get

Returns the value corresponding to the given key, or null if such a key is not present in the map.

operator fun <K, V> Map<out K, V>.get(key: K): V?
JVM
JRE8
1.2

getOrDefault

Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

fun <K, V> Map<out K, V>.getOrDefault(
    key: K,
    defaultValue: V
): V
Common
JVM
JS
Native
1.0

getOrElse

Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this array.

fun <T> any_array<T>.getOrElse(
    index: Int,
    defaultValue: (Int) -> T
): T

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.

fun <T> List<T>.getOrElse(
    index: Int,
    defaultValue: (Int) -> T
): T

Returns the value for the given key, or the result of the defaultValue function if there was no entry for the given key.

fun <K, V> Map<K, V>.getOrElse(
    key: K,
    defaultValue: () -> V
): V
Common
JVM
JS
Native
1.0

getOrNull

Returns an element at the given index or null if the index is out of bounds of this array.

fun <T> any_array<T>.getOrNull(index: Int): T?

Returns an element at the given index or null if the index is out of bounds of this list.

fun <T> List<T>.getOrNull(index: Int): T?
Common
JVM
JS
Native
1.0

getOrPut

Returns the value for the given key. If the key is not found in the map, calls the defaultValue function, puts its result into the map under the given key and returns it.

fun <K, V> MutableMap<K, V>.getOrPut(
    key: K,
    defaultValue: () -> V
): V
Common
JVM
JS
Native
1.0

getValue

Returns the value of the property for the given object from this read-only map.

operator fun <V, V1 : V> Map<in String, V>.getValue(
    thisRef: Any?,
    property: KProperty<*>
): V1

Returns the value of the property for the given object from this mutable map.

operator fun <V, V1 : V> MutableMap<in String, out V>.getValue(
    thisRef: Any?,
    property: KProperty<*>
): V1

Returns the value for the given key or throws an exception if there is no such key in the map.

fun <K, V> Map<K, V>.getValue(key: K): V
Common
JVM
JS
Native
1.0

groupBy

Groups elements of the original array 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.

fun <T, K> any_array<T>.groupBy(
    keySelector: (T) -> K
): Map<K, List<T>>

Groups values returned by the valueTransform function applied to each element of the original array 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.

fun <T, K, V> any_array<T>.groupBy(
    keySelector: (T) -> K,
    valueTransform: (T) -> V
): Map<K, List<V>>

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.

fun <T, K> Iterable<T>.groupBy(
    keySelector: (T) -> K
): Map<K, List<T>>

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.

fun <T, K, V> Iterable<T>.groupBy(
    keySelector: (T) -> K,
    valueTransform: (T) -> V
): Map<K, List<V>>
Common
JVM
JS
Native
1.0

groupByTo

Groups elements of the original array 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.

fun <T, K, M : MutableMap<in K, MutableList<T>>> any_array<T>.groupByTo(
    destination: M,
    keySelector: (T) -> K
): M

Groups values returned by the valueTransform function applied to each element of the original array 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.

fun <T, K, V, M : MutableMap<in K, MutableList<V>>> any_array<T>.groupByTo(
    destination: M,
    keySelector: (T) -> K,
    valueTransform: (T) -> V
): M

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.

fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(
    destination: M,
    keySelector: (T) -> K
): M

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.

fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(
    destination: M,
    keySelector: (T) -> K,
    valueTransform: (T) -> V
): M
Common
JVM
JS
Native
1.1

groupingBy

Creates a Grouping source from an array to be used later with one of group-and-fold operations using the specified keySelector function to extract a key from each element.

fun <T, K> Array<out T>.groupingBy(
    keySelector: (T) -> K
): Grouping<T, K>

Creates a Grouping source from a collection to be used later with one of group-and-fold operations using the specified keySelector function to extract a key from each element.

fun <T, K> Iterable<T>.groupingBy(
    keySelector: (T) -> K
): Grouping<T, K>
Common
JVM
JS
Native
1.0

hashMapOf

Returns an empty new HashMap.

fun <K, V> hashMapOf(): HashMap<K, V>

Returns a new HashMap with the specified contents, given as a list of pairs where the first component is the key and the second is the value.

fun <K, V> hashMapOf(vararg pairs: Pair<K, V>): HashMap<K, V>
Common
JVM
JS
Native
1.0

hashSetOf

Returns an empty new HashSet.

fun <T> hashSetOf(): HashSet<T>

Returns a new HashSet with the given elements.

fun <T> hashSetOf(vararg elements: T): HashSet<T>
Common
JVM
JS
Native
1.3

ifEmpty

Returns this array if it's not empty or the result of calling defaultValue function if the array is empty.

fun <C, R> C.ifEmpty(
    defaultValue: () -> R
): R where C : Array<*>, C : R

Returns this map if it's not empty or the result of calling defaultValue function if the map is empty.

fun <M, R> M.ifEmpty(
    defaultValue: () -> R
): R where M : Map<*, *>, M : R
Common
JVM
JS
Native
1.0

indexOf

Returns first index of element, or -1 if the array does not contain element.

fun <T> any_array<T>.indexOf(element: T): Int

Returns first index of element, or -1 if the collection does not contain element.

fun <T> Iterable<T>.indexOf(element: T): Int

Returns first index of element, or -1 if the list does not contain element.

fun <T> List<T>.indexOf(element: T): Int
Common
JVM
JS
Native
1.0

indexOfFirst

Returns index of the first element matching the given predicate, or -1 if the array does not contain such element.

fun <T> any_array<T>.indexOfFirst(
    predicate: (T) -> Boolean
): Int

Returns index of the first element matching the given predicate, or -1 if the collection does not contain such element.

fun <T> Iterable<T>.indexOfFirst(
    predicate: (T) -> Boolean
): Int

Returns index of the first element matching the given predicate, or -1 if the list does not contain such element.

fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int
Common
JVM
JS
Native
1.0

indexOfLast

Returns index of the last element matching the given predicate, or -1 if the array does not contain such element.

fun <T> any_array<T>.indexOfLast(
    predicate: (T) -> Boolean
): Int

Returns index of the last element matching the given predicate, or -1 if the collection does not contain such element.

fun <T> Iterable<T>.indexOfLast(
    predicate: (T) -> Boolean
): Int

Returns index of the last element matching the given predicate, or -1 if the list does not contain such element.

fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int
Common
JVM
JS
Native
1.0

intersect

Returns a set containing all elements that are contained by both this set and the specified collection.

infix fun <T> Array<out T>.intersect(
    other: Iterable<T>
): Set<T>
infix fun ByteArray.intersect(
    other: Iterable<Byte>
): Set<Byte>
infix fun ShortArray.intersect(
    other: Iterable<Short>
): Set<Short>
infix fun IntArray.intersect(other: Iterable<Int>): Set<Int>
infix fun LongArray.intersect(
    other: Iterable<Long>
): Set<Long>
infix fun FloatArray.intersect(
    other: Iterable<Float>
): Set<Float>
infix fun DoubleArray.intersect(
    other: Iterable<Double>
): Set<Double>
infix fun BooleanArray.intersect(
    other: Iterable<Boolean>
): Set<Boolean>
infix fun CharArray.intersect(
    other: Iterable<Char>
): Set<Char>
infix fun <T> Iterable<T>.intersect(
    other: Iterable<T>
): Set<T>
Common
JVM
JS
Native
1.0

isEmpty

Returns true if the array is empty.

fun <T> any_array<T>.isEmpty(): Boolean
Common
JVM
JS
Native
1.0

isNotEmpty

Returns true if the array is not empty.

fun <T> any_array<T>.isNotEmpty(): Boolean

Returns true if the collection is not empty.

fun <T> Collection<T>.isNotEmpty(): Boolean

Returns true if this map is not empty.

fun <K, V> Map<out K, V>.isNotEmpty(): Boolean
Common
JVM
JS
Native
1.3

isNullOrEmpty

Returns true if this nullable array is either null or empty.

fun Array<*>?.isNullOrEmpty(): Boolean

Returns true if this nullable collection is either null or empty.

fun <T> Collection<T>?.isNullOrEmpty(): Boolean

Returns true if this nullable map is either null or empty.

fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean
Common
JVM
JS
Native
1.0

Iterable

Given an iterator function constructs an Iterable instance that returns values through the Iterator provided by that function.

fun <T> Iterable(iterator: () -> Iterator<T>): Iterable<T>
Common
JVM
JS
Native
1.0

iterator

Returns the given iterator itself. This allows to use an instance of iterator in a for loop.

operator fun <T> Iterator<T>.iterator(): Iterator<T>

Returns an Iterator over the entries in the Map.

operator fun <K, V> Map<out K, V>.iterator(): Iterator<Entry<K, V>>

Returns a MutableIterator over the mutable entries in the MutableMap.

operator fun <K, V> MutableMap<K, V>.iterator(): MutableIterator<MutableEntry<K, V>>
Common
JVM
JS
Native
1.0

joinTo

Appends the string from all the elements separated using separator and using the given prefix and postfix if supplied.

fun <T, A : Appendable> Array<out T>.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (T) -> CharSequence = null
): A
fun <A : Appendable> ByteArray.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Byte) -> CharSequence = null
): A
fun <A : Appendable> ShortArray.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Short) -> CharSequence = null
): A
fun <A : Appendable> IntArray.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Int) -> CharSequence = null
): A
fun <A : Appendable> LongArray.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Long) -> CharSequence = null
): A
fun <A : Appendable> FloatArray.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Float) -> CharSequence = null
): A
fun <A : Appendable> DoubleArray.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Double) -> CharSequence = null
): A
fun <A : Appendable> BooleanArray.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Boolean) -> CharSequence = null
): A
fun <A : Appendable> CharArray.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Char) -> CharSequence = null
): A
fun <T, A : Appendable> Iterable<T>.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (T) -> CharSequence = null
): A
Common
JVM
JS
Native
1.0

joinToString

Creates a string from all the elements separated using separator and using the given prefix and postfix if supplied.

fun <T> Array<out T>.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (T) -> CharSequence = null
): String
fun ByteArray.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Byte) -> CharSequence = null
): String
fun ShortArray.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Short) -> CharSequence = null
): String
fun IntArray.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Int) -> CharSequence = null
): String
fun LongArray.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Long) -> CharSequence = null
): String
fun FloatArray.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Float) -> CharSequence = null
): String
fun DoubleArray.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Double) -> CharSequence = null
): String
fun BooleanArray.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Boolean) -> CharSequence = null
): String
fun CharArray.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (Char) -> CharSequence = null
): String
fun <T> Iterable<T>.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (T) -> CharSequence = null
): String
Common
JVM
JS
Native
1.0

last

Returns the last element.

fun <T> Array<out T>.last(): T
fun ByteArray.last(): Byte
fun ShortArray.last(): Short
fun IntArray.last(): Int
fun LongArray.last(): Long
fun FloatArray.last(): Float
fun DoubleArray.last(): Double
fun BooleanArray.last(): Boolean
fun CharArray.last(): Char
fun <T> Iterable<T>.last(): T
fun <T> List<T>.last(): T

Returns the last element matching the given predicate.

fun <T> Array<out T>.last(predicate: (T) -> Boolean): T
fun ByteArray.last(predicate: (Byte) -> Boolean): Byte
fun ShortArray.last(predicate: (Short) -> Boolean): Short
fun IntArray.last(predicate: (Int) -> Boolean): Int
fun LongArray.last(predicate: (Long) -> Boolean): Long
fun FloatArray.last(predicate: (Float) -> Boolean): Float
fun DoubleArray.last(predicate: (Double) -> Boolean): Double
fun BooleanArray.last(
    predicate: (Boolean) -> Boolean
): Boolean
fun CharArray.last(predicate: (Char) -> Boolean): Char
fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T
fun <T> List<T>.last(predicate: (T) -> Boolean): T
Common
JVM
JS
Native
1.0

lastIndexOf

Returns last index of element, or -1 if the array does not contain element.

fun <T> any_array<T>.lastIndexOf(element: T): Int

Returns last index of element, or -1 if the collection does not contain element.

fun <T> Iterable<T>.lastIndexOf(element: T): Int

Returns last index of element, or -1 if the list does not contain element.

fun <T> List<T>.lastIndexOf(element: T): Int
Common
JVM
JS
Native
1.0

lastOrNull

Returns the last element, or null if the array is empty.

fun <T> any_array<T>.lastOrNull(): T?

Returns the last element matching the given predicate, or null if no such element was found.

fun <T> Array<out T>.lastOrNull(
    predicate: (T) -> Boolean
): T?
fun ByteArray.lastOrNull(predicate: (Byte) -> Boolean): Byte?
fun ShortArray.lastOrNull(
    predicate: (Short) -> Boolean
): Short?
fun IntArray.lastOrNull(predicate: (Int) -> Boolean): Int?
fun LongArray.lastOrNull(predicate: (Long) -> Boolean): Long?
fun FloatArray.lastOrNull(
    predicate: (Float) -> Boolean
): Float?
fun DoubleArray.lastOrNull(
    predicate: (Double) -> Boolean
): Double?
fun BooleanArray.lastOrNull(
    predicate: (Boolean) -> Boolean
): Boolean?
fun CharArray.lastOrNull(predicate: (Char) -> Boolean): Char?
fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T?
fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T?

Returns the last element, or null if the collection is empty.

fun <T> Iterable<T>.lastOrNull(): T?

Returns the last element, or null if the list is empty.

fun <T> List<T>.lastOrNull(): T?
Common
JVM
JS
Native
1.0

linkedMapOf

Returns an empty new LinkedHashMap.

fun <K, V> linkedMapOf(): LinkedHashMap<K, V>

Returns a new LinkedHashMap with the specified contents, given as a list of pairs where the first component is the key and the second is the value.

fun <K, V> linkedMapOf(
    vararg pairs: Pair<K, V>
): LinkedHashMap<K, V>
Common
JVM
JS
Native
1.0

linkedSetOf

Returns an empty new LinkedHashSet.

fun <T> linkedSetOf(): LinkedHashSet<T>

Returns a new LinkedHashSet with the given elements. Elements of the set are iterated in the order they were specified.

fun <T> linkedSetOf(vararg elements: T): LinkedHashSet<T>
JS
1.1

linkedStringMapOf

Constructs the specialized implementation of LinkedHashMap with String keys, which stores the keys as properties of JS object without hashing them.

fun <V> linkedStringMapOf(
    vararg pairs: Pair<String, V>
): LinkedHashMap<String, V>
JS
1.1

linkedStringSetOf

Creates a new instance of the specialized implementation of LinkedHashSet with the specified String elements, which elements the keys as properties of JS object without hashing them.

fun linkedStringSetOf(
    vararg elements: String
): LinkedHashSet<String>
Common
JVM
JS
Native
1.1

List

Creates a new read-only list with the specified size, where each element is calculated by calling the specified init function. The init function returns a list element given its index.

fun <T> List(size: Int, init: (index: Int) -> T): List<T>

listOf

Common
JVM
JS
Native
1.0

Returns a new read-only list of given elements. The returned list is serializable (JVM).

fun <T> listOf(vararg elements: T): List<T>
Common
JVM
JS
Native
1.0

Returns an empty read-only list. The returned list is serializable (JVM).

fun <T> listOf(): List<T>
JVM
JS
1.0

Returns an immutable list containing only the specified object element. The returned list is serializable.

fun <T> listOf(element: T): List<T>
Common
JVM
JS
Native
1.0

listOfNotNull

Returns a new read-only list either of single given element, if it is not null, or empty list if the element is null. The returned list is serializable (JVM).

fun <T : Any> listOfNotNull(element: T?): List<T>

Returns a new read-only list only of those given elements, that are not null. The returned list is serializable (JVM).

fun <T : Any> listOfNotNull(vararg elements: T?): List<T>
Common
JVM
JS
Native
1.0

map

Returns a list containing the results of applying the given transform function to each element in the original array.

fun <T, R> any_array<T>.map(transform: (T) -> R): List<R>

Returns a list containing the results of applying the given transform function to each element in the original collection.

fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R>

Returns a list containing the results of applying the given transform function to each entry in the original map.

fun <K, V, R> Map<out K, V>.map(
    transform: (Entry<K, V>) -> R
): List<R>
Common
JVM
JS
Native
1.0

mapIndexed

Returns a list containing the results of applying the given transform function to each element and its index in the original array.

fun <T, R> any_array<T>.mapIndexed(
    transform: (index: Int, T) -> R
): List<R>

Returns a list containing the results of applying the given transform function to each element and its index in the original collection.

fun <T, R> Iterable<T>.mapIndexed(
    transform: (index: Int, T) -> R
): List<R>
Common
JVM
JS
Native
1.0

mapIndexedNotNull

Returns a list containing only the non-null results of applying the given transform function to each element and its index in the original array.

fun <T, R : Any> Array<out T>.mapIndexedNotNull(