W3cubDocs

/Kotlin

Package kotlin.collections

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

Types

AbstractCollection

abstract class AbstractCollection<out E> : Collection<E>

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

AbstractIterator

abstract class AbstractIterator<T> : Iterator<T>

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.

AbstractList

abstract class AbstractList<out E> : 
    AbstractCollection<E>, 
    List<E>

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

AbstractMap

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

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

AbstractMutableCollection

abstract class AbstractMutableCollection<E> : 
    MutableCollection<E>, 
    AbstractCollection<E>

Provides a skeletal implementation of the MutableCollection interface.

AbstractMutableList

abstract class AbstractMutableList<E> : 
    MutableList<E>, 
    AbstractList<E>

Provides a skeletal implementation of the MutableList interface.

AbstractMutableMap

abstract class AbstractMutableMap<K, V> : 
    MutableMap<K, V>, 
    AbstractMap<K, V>

Provides a skeletal implementation of the MutableMap interface.

AbstractMutableSet

abstract class AbstractMutableSet<E> : 
    MutableSet<E>, 
    AbstractSet<E>

Provides a skeletal implementation of the MutableSet interface.

AbstractSet

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

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

BooleanIterator

abstract class BooleanIterator : Iterator<Boolean>

An iterator over a sequence of values of type Boolean.

ByteIterator

abstract class ByteIterator : Iterator<Byte>

An iterator over a sequence of values of type Byte.

CharIterator

abstract class CharIterator : Iterator<Char>

An iterator over a sequence of values of type Char.

Collection

interface Collection<out E> : Iterable<E>

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.

DoubleIterator

abstract class DoubleIterator : Iterator<Double>

An iterator over a sequence of values of type Double.

FloatIterator

abstract class FloatIterator : Iterator<Float>

An iterator over a sequence of values of type Float.

Grouping

interface Grouping<T, out K>

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

IndexedValue

data class IndexedValue<out T>

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

IntIterator

abstract class IntIterator : Iterator<Int>

An iterator over a sequence of values of type Int.

Iterable

interface Iterable<out T>

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

Iterator

interface Iterator<out T>

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

List

interface List<out E> : Collection<E>

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.

ListIterator

interface ListIterator<out T> : Iterator<T>

An iterator over a collection that supports indexed access.

LongIterator

abstract class LongIterator : Iterator<Long>

An iterator over a sequence of values of type Long.

Map

interface Map<K, out V>

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.

MutableCollection

interface MutableCollection<E> : 
    Collection<E>, 
    MutableIterable<E>

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

MutableIterable

interface MutableIterable<out T> : Iterable<T>

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.

MutableIterator

interface MutableIterator<out T> : Iterator<T>

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

MutableList

interface MutableList<E> : List<E>, MutableCollection<E>

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

MutableListIterator

interface MutableListIterator<T> : 
    ListIterator<T>, 
    MutableIterator<T>

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

MutableMap

interface MutableMap<K, V> : Map<K, V>

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.

MutableSet

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

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

Set

interface Set<out E> : Collection<E>

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.

ShortIterator

abstract class ShortIterator : Iterator<Short>

An iterator over a sequence of values of type Short.

Type Aliases

ArrayList

typealias ArrayList<E> = ArrayList<E>

HashMap

typealias HashMap<K, V> = HashMap<K, V>

HashSet

typealias HashSet<E> = HashSet<E>

LinkedHashMap

typealias LinkedHashMap<K, V> = LinkedHashMap<K, V>

LinkedHashSet

typealias LinkedHashSet<E> = LinkedHashSet<E>

RandomAccess

typealias RandomAccess = RandomAccess

Extensions for External Classes

java.util.Enumeration

java.util.concurrent.ConcurrentMap

Properties

indices

val Collection<*>.indices: IntRange

Returns an IntRange of the valid indices for this collection.

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

Returns the range of valid indices for the array.

lastIndex

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

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

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

Returns the last valid index for the array.

Functions

Iterable

fun <T> Iterable(iterator: () -> Iterator<T>): Iterable<T>

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

List

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

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.

MutableList

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

Creates a new mutable 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.

addAll

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

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

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

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

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

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

aggregate

fun <T, K, R> Grouping<T, K>.aggregate(
    operation: (key: K, accumulator: R?, element: T, first: Boolean) -> 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.

aggregateTo

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

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.

all

fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean
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

Returns true if all elements match the given predicate.

fun <K, V> Map<out K, V>.all(
    predicate: (Entry<K, V>) -> Boolean
): Boolean

Returns true if all entries match the given predicate.

any

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

Returns true if collection has at least one element.

fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean
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

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

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

Returns true if map has at least one entry.

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

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

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

Returns true if array has at least one element.

arrayListOf

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

Returns an empty new ArrayList.

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

Returns a new ArrayList with the given elements.

asIterable

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

Returns this collection as an Iterable.

fun <K, V> Map<out K, V>.asIterable(): Iterable<Entry<K, V>>

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

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

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

asList

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

Returns a List that wraps the original array.

asReversed

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

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> MutableList<T>.asReversed(): MutableList<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.

asSequence

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

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

fun <K, V> Map<out K, V>.asSequence(): Sequence<Entry<K, V>>

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

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

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

associate

fun <T, K, V> Iterable<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> 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 array.

associateBy

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

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, V> Iterable<T>.associateBy(
    keySelector: (T) -> K, 
    valueTransform: (T) -> V
): Map<K, V>

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

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

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, V> any_array<T>.associateBy(
    keySelector: (T) -> K, 
    valueTransform: (T) -> V
): Map<K, V>

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

associateByTo

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 applied to each element of the given collection and value is the element itself.

fun <T, K, V, M : MutableMap<in K, in V>> Iterable<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 and and value is provided by the valueTransform function applied to elements of the given collection.

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 applied to each element of the given array and value is the element itself.

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 and and value is provided by the valueTransform function applied to elements of the given array.

associateTo

fun <T, K, V, M : MutableMap<in K, in V>> Iterable<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>> 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 array.

average

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

Returns an average value of elements in the collection.

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

binarySearch

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

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> List<T>.binarySearch(
    element: T, 
    comparator: Comparator<in T>, 
    fromIndex: Int = 0, 
    toIndex: Int = size
): Int
fun <T> List<T>.binarySearch(
    element: T, 
    comparator: Comparator<in T>, 
    fromIndex: Int = 0, 
    toIndex: Int = size
): Int

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(
    fromIndex: Int = 0, 
    toIndex: Int = size, 
    comparison: (T) -> Int
): Int

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> Array<out T>.binarySearch(
    element: T, 
    comparator: Comparator<in T>, 
    fromIndex: Int = 0, 
    toIndex: Int = size
): Int

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> any_array<T>.binarySearch(
    element: T, 
    fromIndex: Int = 0, 
    toIndex: Int = size
): Int

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.

binarySearchBy

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

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.

component1

operator fun <K, V> Entry<K, V>.component1(): K

Returns the key component of the map entry.

operator fun <T> List<T>.component1(): T
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

Returns 1st element from the collection.

component2

operator fun <K, V> Entry<K, V>.component2(): V

Returns the value component of the map entry. This method allows to use destructuring declarations when working with maps, for example:

operator fun <T> List<T>.component2(): T
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

Returns 2nd element from the collection.

component3

operator fun <T> List<T>.component3(): T
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

Returns 3rd element from the collection.

component4

operator fun <T> List<T>.component4(): T
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

Returns 4th element from the collection.

component5

operator fun <T> List<T>.component5(): T
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

Returns 5th element from the collection.

contains

operator fun <K, V> Map<out K, V>.contains(key: K): Boolean

Checks if the map contains the given key. This method allows to use the x in map syntax for checking whether an object is contained in the map.

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

Returns true if element is found in the collection.

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

Returns true if element is found in the array.

containsAll

fun <T> Collection<T>.containsAll(
    elements: Collection<T>
): Boolean

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

containsKey

fun <K> Map<out K, *>.containsKey(key: K): Boolean

Returns true if the map contains the specified key.

containsValue

fun <K, V> Map<K, V>.containsValue(value: V): Boolean

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

contentDeepEquals

infix fun <T> Array<out T>.contentDeepEquals(
    other: Array<out T>
): Boolean

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.

contentDeepHashCode

fun <T> Array<out T>.contentDeepHashCode(): Int

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

contentDeepToString

fun <T> Array<out T>.contentDeepToString(): String

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

contentEquals

infix fun <T> any_array<T>.contentEquals(
    other: Array<out T>
): Boolean

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.

contentHashCode

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

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

contentToString

fun <T> any_array<T>.contentToString(): String

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

copyOf

fun <T> any_array<T>.copyOf(): Array<T>

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

fun <T> any_array<T>.copyOf(newSize: Int): Array<T?>

Returns new array which is a copy of the original array, resized to the given newSize.

copyOfRange

fun <T> any_array<T>.copyOfRange(
    fromIndex: Int, 
    toIndex: Int
): Array<T>

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

count

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

Returns the number of elements in this collection.

fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int
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

Returns the number of elements matching the given predicate.

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

Returns the number of entries in this map.

fun <K, V> Map<out K, V>.count(
    predicate: (Entry<K, V>) -> Boolean
): Int

Returns the number of entries matching the given predicate.

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

Returns the number of elements in this array.

distinct

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

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

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

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

distinctBy

fun <T, K> Iterable<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> any_array<T>.distinctBy(
    selector: (T) -> K
): List<T>

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

drop

fun <T> Iterable<T>.drop(n: Int): List<T>
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>

Returns a list containing all elements except first n elements.

dropLast

fun <T> List<T>.dropLast(n: Int): List<T>
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>

Returns a list containing all elements except last n elements.

dropLastWhile

fun <T> List<T>.dropLastWhile(
    predicate: (T) -> Boolean
): List<T>
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>

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

dropWhile

fun <T> Iterable<T>.dropWhile(
    predicate: (T) -> Boolean
): List<T>
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>

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

eachCount

fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int>

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

eachCountTo

fun <T, K, M : MutableMap<in K, Int>> Grouping<T, K>.eachCountTo(
    destination: M
): M

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

elementAt

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

fun <T> List<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> 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 array.

elementAtOrElse

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

fun <T> List<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> 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 array.

elementAtOrNull

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

fun <T> List<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> 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 array.

emptyList

fun <T> emptyList(): List<T>

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

emptyMap

fun <K, V> emptyMap(): Map<K, V>

Returns an empty read-only map of specified type. The returned map is serializable (JVM).

emptySet

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

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

fill

fun <T> any_array<T>.fill(
    element: T, 
    fromIndex: Int = 0, 
    toIndex: Int = size)

Fills original array with the provided value.

filter

fun <K, V> Map<out K, V>.filter(
    predicate: (Entry<K, V>) -> Boolean
): Map<K, V>

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

fun <T> Iterable<T>.filter(
    predicate: (T) -> Boolean
): List<T>
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>

Returns a list containing only elements matching the given predicate.

filterIndexed

fun <T> Iterable<T>.filterIndexed(
    predicate: (index: Int, T) -> Boolean
): List<T>
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>

Returns a list containing only elements matching the given predicate.

filterIndexedTo

fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(
    destination: C, 
    predicate: (index: Int, T) -> Boolean
): C
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

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

filterIsInstance

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

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

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

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

filterIsInstanceTo

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

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

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

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

filterKeys

fun <K, V> Map<out K, V>.filterKeys(
    predicate: (K) -> Boolean
): Map<K, V>

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

filterNot

fun <K, V> Map<out K, V>.filterNot(
    predicate: (Entry<K, V>) -> Boolean
): Map<K, V>

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

fun <T> Iterable<T>.filterNot(
    predicate: (T) -> Boolean
): List<T>
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>

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

filterNotNull

fun <T : Any> Iterable<T?>.filterNotNull(): List<T>
fun <T : Any> Array<out T?>.filterNotNull(): List<T>

Returns a list containing all elements that are not null.

filterNotNullTo

fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(
    destination: C
): C
fun <C : MutableCollection<in T>, T : Any> Array<out T?>.filterNotNullTo(
    destination: C
): C

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

filterNotTo

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

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

fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(
    destination: C, 
    predicate: (T) -> Boolean
): C
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

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

filterTo

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

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

fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(
    destination: C, 
    predicate: (T) -> Boolean
): C
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

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

filterValues

fun <K, V> Map<out K, V>.filterValues(
    predicate: (V) -> Boolean
): Map<K, V>

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

find

fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T?
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?

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

findLast

fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T?
fun <T> List<T>.findLast(predicate: (T) -> Boolean): T?
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?

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

first

fun <T> Iterable<T>.first(): T
fun <T> List<T>.first(): T
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

Returns first element.

fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T
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

Returns the first element matching the given predicate.

firstOrNull

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

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

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

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

fun <T> Iterable<T>.firstOrNull(
    predicate: (T) -> Boolean
): T?
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?

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

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

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

flatMap

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 element of original collection.

fun <K, V, R> Map<out K, V>.flatMap(
    transform: (Entry<K, V>) -> 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 <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 array.

flatMapTo

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 element of original collection, 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

Appends all elements yielded from results of transform function being invoked on each entry of original map, 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 array, to the given destination.

flatten

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

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

fun <T> Iterable<Iterable<T>>.flatten(): List<T>

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

fold

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 provided by initialValueSelector function.

fun <T, K, R> Grouping<T, K>.fold(
    initialValue: R, 
    operation: (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, R> Iterable<T>.fold(
    initial: R, 
    operation: (acc: R, T) -> R
): R
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

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

foldIndexed

fun <T, R> Iterable<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> 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 array.

foldRight

fun <T, R> List<T>.foldRight(
    initial: R, 
    operation: (T, acc: R) -> R
): R
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

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

foldRightIndexed

fun <T, R> List<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> 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 array and current accumulator value.

foldTo

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 provided by initialValueSelector function.

fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(
    destination: M, 
    initialValue: R, 
    operation: (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.

forEach

fun <T> Iterator<T>.forEach(operation: (T) -> Unit)

Performs the given operation on each element of this Iterator.

fun <T> Iterable<T>.forEach(action: (T) -> Unit)
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)

Performs the given action on each element.

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

Performs the given action on each entry.

forEachIndexed

fun <T> Iterable<T>.forEachIndexed(
    action: (index: Int, T) -> Unit)
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)

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

get

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

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

getOrDefault

fun <K, V> Map<out K, V>.getOrDefault(
    key: K, 
    defaultValue: V
): V

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

getOrElse

fun <K, V> Map<K, V>.getOrElse(
    key: K, 
    defaultValue: () -> V
): V

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

fun <T> List<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> 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 array.

getOrNull

fun <T> List<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> 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 array.

getOrPut

fun <K, V> MutableMap<K, V>.getOrPut(
    key: K, 
    defaultValue: () -> V
): V

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.

getValue

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 read-only map.

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

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

fun <K, V> Map<K, V>.getValue(key: K): V

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

groupBy

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

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, V> Iterable<T>.groupBy(
    keySelector: (T) -> K, 
    valueTransform: (T) -> V
): Map<K, List<V>>

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> any_array<T>.groupBy(
    keySelector: (T) -> K
): Map<K, List<T>>

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, V> any_array<T>.groupBy(
    keySelector: (T) -> K, 
    valueTransform: (T) -> V
): Map<K, List<V>>

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.

groupByTo

fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(
    destination: M, 
    keySelector: (T) -> K
): 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, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(
    destination: M, 
    keySelector: (T) -> K, 
    valueTransform: (T) -> V
): 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, M : MutableMap<in K, MutableList<T>>> any_array<T>.groupByTo(
    destination: M, 
    keySelector: (T) -> K
): M

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, V, M : MutableMap<in K, MutableList<V>>> any_array<T>.groupByTo(
    destination: M, 
    keySelector: (T) -> K, 
    valueTransform: (T) -> V
): 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.

groupingBy

fun <T, K> Iterable<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> Array<out T>.groupingBy(
    keySelector: (T) -> K
): Grouping<T, K>

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.

hashMapOf

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

Returns an empty new HashMap.

fun <K, V> hashMapOf(vararg pairs: Pair<K, V>): 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.

hashSetOf

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

Returns an empty new HashSet.

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

Returns a new HashSet with the given elements.

indexOf

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

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

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

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

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

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

indexOfFirst

fun <T> Iterable<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> List<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> any_array<T>.indexOfFirst(
    predicate: (T) -> Boolean
): Int

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

indexOfLast

fun <T> Iterable<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> List<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> any_array<T>.indexOfLast(
    predicate: (T) -> Boolean
): Int

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

intersect

infix fun <T> Iterable<T>.intersect(
    other: Iterable<T>
): Set<T>
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>

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

isEmpty

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

Returns true if the array is empty.

isNotEmpty

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

Returns true if this map is not empty.

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

Returns true if the collection is not empty.

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

Returns true if the array is not empty.

iterator

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

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

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

Returns an Iterator over the entries in the Map.

operator fun <K, V> MutableMap<K, V>.iterator(): MutableIterator<MutableEntry<K, V>>

Returns a MutableIterator over the mutable entries in the MutableMap.

joinTo

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

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

joinToString

fun <T> Iterable<T>.joinToString(
    separator: CharSequence = ", ", 
    prefix: CharSequence = "", 
    postfix: CharSequence = "", 
    limit: Int = -1, 
    truncated: CharSequence = "...", 
    transform: (T) -> CharSequence = null
): String
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

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

last

fun <T> Iterable<T>.last(): T
fun <T> List<T>.last(): T
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

Returns the last element.

fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T
fun <T> List<T>.last(predicate: (T) -> Boolean): T
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

Returns the last element matching the given predicate.

lastIndexOf

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

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

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

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

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

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

lastOrNull

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

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

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

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

fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T?
fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T?
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?

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

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

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

linkedMapOf

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

Returns an empty new LinkedHashMap.

fun <K, V> linkedMapOf(
    vararg pairs: Pair<K, V>
): 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. If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs. Entries of the map are iterated in the order they were specified.

linkedSetOf

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

Returns an empty new LinkedHashSet.

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

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

linkedStringMapOf

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

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

linkedStringSetOf

fun linkedStringSetOf(
    vararg elements: String
): LinkedHashSet<String>

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.

listOf

fun <T> listOf(vararg elements: T): List<T>

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

fun <T> listOf(): List<T>

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

fun <T> listOf(element: T): List<T>

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

listOfNotNull

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

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

fun <T : Any> listOfNotNull(vararg elements: T?): List<T>

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

map

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 element in the original collection.

fun <K, V, R> Map<out K, V>.map(
    transform: (Entry<K, V>) -> R
): List<R>

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

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

mapIndexed

fun <T, R> Iterable<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> 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 array.

mapIndexedNotNull

fun <T, R : Any> Iterable<T>.mapIndexedNotNull(
    transform: (index: Int, T) -> R?
): List<R>

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.

fun <T, R : Any> Array<out T>.mapIndexedNotNull(
    transform: (index: Int, T) -> R?
): List<R>

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.

mapIndexedNotNullTo

fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(
    destination: C, 
    transform: (index: Int, T) -> R?
): C

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.

fun <T, R : Any, C : MutableCollection<in R>> Array<out T>.mapIndexedNotNullTo(
    destination: C, 
    transform: (index: Int, T) -> R?
): C

Applies the given transform function to each element and its index in the original array and appends only the non-null results to the given destination.

mapIndexedTo

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

Applies the given transform function to each element and its index in the original collection and appends the results to the given destination.

fun <T, R, C : MutableCollection<in R>> any_array<T>.mapIndexedTo(
    destination: C, 
    transform: (index: Int, T) -> R
): C

Applies the given transform function to each element and its index in the original array and appends the results to the given destination.

mapKeys

fun <K, V, R> Map<out K, V>.mapKeys(
    transform: (Entry<K, V>) -> R
): Map<R, V>

Returns a new Map with entries having the keys obtained by applying the transform function to each entry in this Map and the values of this map.

mapKeysTo

fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(
    destination: M, 
    transform: (Entry<K, V>) -> R
): M

Populates the given destination map with entries having the keys obtained by applying the transform function to each entry in this Map and the values of this map.

mapNotNull

fun <T, R : Any> Iterable<T>.mapNotNull(
    transform: (T) -> R?
): List<R>

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

fun <K, V, R : Any> Map<out K, V>.mapNotNull(
    transform: (Entry<K, V>) -> R?
): List<R>

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

fun <T, R : Any> Array<out T>.mapNotNull(
    transform: (T) -> R?
): List<R>

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

mapNotNullTo

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

Applies the given transform function to each element in the original collection and appends only the non-null results to the given destination.

fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(
    destination: C, 
    transform: (Entry<K, V>) -> R?
): C

Applies the given transform function to each entry in the original map and appends only the non-null results to the given destination.

fun <T, R : Any, C : MutableCollection<in R>> Array<out T>.mapNotNullTo(
    destination: C, 
    transform: (T) -> R?
): C

Applies the given transform function to each element in the original array and appends only the non-null results to the given destination.

mapOf

fun <K, V> mapOf(vararg pairs: Pair<K, V>): Map<K, V>

Returns a new read-only map with the specified contents, given as a list of pairs where the first value is the key and the second is the value. If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.

fun <K, V> mapOf(): Map<K, V>

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

fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V>

Returns an immutable map, mapping only the specified key to the specified value. The returned map is serializable.

mapTo

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

Applies the given transform function to each element of the original collection and appends the results to the given destination.

fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(
    destination: C, 
    transform: (Entry<K, V>) -> R
): C

Applies the given transform function to each entry of the original map and appends the results to the given destination.

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

Applies the given transform function to each element of the original array and appends the results to the given destination.

mapValues

fun <K, V, R> Map<out K, V>.mapValues(
    transform: (Entry<K, V>) -> R
): Map<K, R>

Returns a new map with entries having the keys of this map and the values obtained by applying the transform function to each entry in this Map.

mapValuesTo

fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(
    destination: M, 
    transform: (Entry<K, V>) -> R
): M

Populates the given destination map with entries having the keys of this map and the values obtained by applying the transform function to each entry in this Map.

max

fun Iterable<Double>.max(): Double?
fun Iterable<Float>.max(): Float?
fun <T : Comparable<T>> Iterable<T>.max(): T?
fun Array<out Double>.max(): Double?
fun Array<out Float>.max(): Float?
fun <T : Comparable<T>> Array<out T>.max(): T?
fun ByteArray.max(): Byte?
fun ShortArray.max(): Short?
fun IntArray.max(): Int?
fun LongArray.max(): Long?
fun FloatArray.max(): Float?
fun DoubleArray.max(): Double?
fun CharArray.max(): Char?

Returns the largest element or null if there are no elements.

maxBy

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

Returns the first element yielding the largest value of the given function or null if there are no elements.

fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(
    selector: (Entry<K, V>) -> R
): Entry<K, V>?

Returns the first entry yielding the largest value of the given function or null if there are no entries.

maxWith

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

Returns the first element having the largest value according to the provided comparator or null if there are no elements.

fun <K, V> Map<out K, V>.maxWith(
    comparator: Comparator<in Entry<K, V>>
): Entry<K, V>?
fun <K, V> Map<out K, V>.maxWith(
    comparator: Comparator<in Entry<K, V>>
): Entry<K, V>?

Returns the first entry having the largest value according to the provided comparator or null if there are no entries.

min

fun Iterable<Double>.min(): Double?
fun Iterable<Float>.min(): Float?
fun <T : Comparable<T>> Iterable<T>.min(): T?
fun Array<out Double>.min(): Double?
fun Array<out Float>.min(): Float?
fun <T : Comparable<T>> Array<out T>.min(): T?
fun ByteArray.min(): Byte?
fun ShortArray.min(): Short?
fun IntArray.min(): Int?
fun LongArray.min(): Long?
fun FloatArray.min(): Float?
fun DoubleArray.min(): Double?
fun CharArray.min(): Char?

Returns the smallest element or null if there are no elements.

minBy

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

Returns the first element yielding the smallest value of the given function or null if there are no elements.

fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(
    selector: (Entry<K, V>) -> R
): Entry<K, V>?

Returns the first entry yielding the smallest value of the given function or null if there are no entries.

minWith

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

Returns the first element having the smallest value according to the provided comparator or null if there are no elements.

fun <K, V> Map<out K, V>.minWith(
    comparator: Comparator<in Entry<K, V>>
): Entry<K, V>?
fun <K, V> Map<out K, V>.minWith(
    comparator: Comparator<in Entry<K, V>>
): Entry<K, V>?

Returns the first entry having the smallest value according to the provided comparator or null if there are no entries.

minus

operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V>

Returns a map containing all entries of the original map except the entry with the given key.

operator fun <K, V> Map<out K, V>.minus(
    keys: Iterable<K>
): Map<K, V>

Returns a map containing all entries of the original map except those entries the keys of which are contained in the given keys collection.

operator fun <K, V> Map<out K, V>.minus(
    keys: Array<out K>
): Map<K, V>

Returns a map containing all entries of the original map except those entries the keys of which are contained in the given keys array.

operator fun <K, V> Map<out K, V>.minus(
    keys: Sequence<K>
): Map<K, V>

Returns a map containing all entries of the original map except those entries the keys of which are contained in the given keys sequence.

operator fun <T> Set<T>.minus(element: T): Set<T>

Returns a set containing all elements of the original set except the given element.

operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T>

Returns a set containing all elements of the original set except the elements contained in the given elements array.

operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T>

Returns a set containing all elements of the original set except the elements contained in the given elements collection.

operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T>

Returns a set containing all elements of the original set except the elements contained in the given elements sequence.

operator fun <T> Iterable<T>.minus(element: T): List<T>

Returns a list containing all elements of the original collection without the first occurrence of the given element.

operator fun <T> Iterable<T>.minus(
    elements: Array<out T>
): List<T>

Returns a list containing all elements of the original collection except the elements contained in the given elements array.

operator fun <T> Iterable<T>.minus(
    elements: Iterable<T>
): List<T>

Returns a list containing all elements of the original collection except the elements contained in the given elements collection.

operator fun <T> Iterable<T>.minus(
    elements: Sequence<T>
): List<T>

Returns a list containing all elements of the original collection except the elements contained in the given elements sequence.

minusAssign

operator fun <T> MutableCollection<in T>.minusAssign(
    element: T)

Removes a single instance of the specified element from this mutable collection.

operator fun <T> MutableCollection<in T>.minusAssign(
    elements: Iterable<T>)

Removes all elements contained in the given elements collection from this mutable collection.

operator fun <T> MutableCollection<in T>.minusAssign(
    elements: Array<T>)

Removes all elements contained in the given elements array from this mutable collection.

operator fun <T> MutableCollection<in T>.minusAssign(
    elements: Sequence<T>)

Removes all elements contained in the given elements sequence from this mutable collection.

operator fun <K, V> MutableMap<K, V>.minusAssign(key: K)

Removes the entry with the given key from this mutable map.

operator fun <K, V> MutableMap<K, V>.minusAssign(
    keys: Iterable<K>)

Removes all entries the keys of which are contained in the given keys collection from this mutable map.

operator fun <K, V> MutableMap<K, V>.minusAssign(
    keys: Array<out K>)

Removes all entries the keys of which are contained in the given keys array from this mutable map.

operator fun <K, V> MutableMap<K, V>.minusAssign(
    keys: Sequence<K>)

Removes all entries from the keys of which are contained in the given keys sequence from this mutable map.

minusElement

fun <T> Set<T>.minusElement(element: T): Set<T>

Returns a set containing all elements of the original set except the given element.

fun <T> Iterable<T>.minusElement(element: T): List<T>

Returns a list containing all elements of the original collection without the first occurrence of the given element.

mutableListOf

fun <T> mutableListOf(): MutableList<T>

Returns an empty new MutableList.

fun <T> mutableListOf(vararg elements: T): MutableList<T>

Returns a new MutableList with the given elements.

mutableMapOf

fun <K, V> mutableMapOf(): MutableMap<K, V>

Returns an empty new MutableMap.

fun <K, V> mutableMapOf(
    vararg pairs: Pair<K, V>
): MutableMap<K, V>

Returns a new MutableMap with the specified contents, given as a list of pairs where the first component is the key and the second is the value. If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs. Entries of the map are iterated in the order they were specified.

mutableSetOf

fun <T> mutableSetOf(): MutableSet<T>

Returns an empty new MutableSet.

fun <T> mutableSetOf(vararg elements: T): MutableSet<T>

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

none

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

Returns true if the collection has no elements.

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

Returns true if no elements match the given predicate.

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

Returns true if the map has no entries.

fun <K, V> Map<out K, V>.none(
    predicate: (Entry<K, V>) -> Boolean
): Boolean

Returns true if no entries match the given predicate.

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

Returns true if the array has no elements.

onEach

fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C

Performs the given action on each element and returns the collection itself afterwards.

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

Performs the given action on each entry and returns the map itself afterwards.

orEmpty

fun <T> Set<T>?.orEmpty(): Set<T>

Returns this Set if it's not null and the empty set otherwise.

fun <T> Array<out T>?.orEmpty(): Array<out T>

Returns the array if it's not null, or an empty array otherwise.

fun <K, V> Map<K, V>?.orEmpty(): Map<K, V>

Returns the Map if its not null, or the empty Map otherwise.

fun <T> Collection<T>?.orEmpty(): Collection<T>

Returns this Collection if it's not null and the empty list otherwise.

fun <T> List<T>?.orEmpty(): List<T>

Returns this List if it's not null and the empty list otherwise.

partition

fun <T> Iterable<T>.partition(
    predicate: (T) -> Boolean
): Pair<List<T>, List<T>>

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.

fun <T> any_array<T>.partition(
    predicate: (T) -> Boolean
): Pair<List<T>, List<T>>

Splits the original array 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

operator fun <K, V> Map<out K, V>.plus(
    pair: Pair<K, V>
): Map<K, V>

Creates a new read-only map by replacing or adding an entry to this map from a given key-value pair.

operator fun <K, V> Map<out K, V>.plus(
    pairs: Iterable<Pair<K, V>>
): Map<K, V>

Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value pairs.

operator fun <K, V> Map<out K, V>.plus(
    pairs: Array<out Pair<K, V>>
): Map<K, V>

Creates a new read-only map by replacing or adding entries to this map from a given array of key-value pairs.

operator fun <K, V> Map<out K, V>.plus(
    pairs: Sequence<Pair<K, V>>
): Map<K, V>

Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value pairs.

operator fun <K, V> Map<out K, V>.plus(
    map: Map<out K, V>
): Map<K, V>

Creates a new read-only map by replacing or adding entries to this map from another map.

operator fun <T> Set<T>.plus(element: T): Set<T>

Returns a set containing all elements of the original set and then the given element if it isn't already in this set.

operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T>

Returns a set containing all elements of the original set and the given elements array, which aren't already in this set.

operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T>

Returns a set containing all elements of the original set and the given elements collection, which aren't already in this set. The returned set preserves the element iteration order of the original set.

operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T>

Returns a set containing all elements of the original set and the given elements sequence, which aren't already in this set.

operator fun <T> Iterable<T>.plus(element: T): List<T>
operator fun <T> Collection<T>.plus(element: T): List<T>

Returns a list containing all elements of the original collection and then the given element.

operator fun <T> Iterable<T>.plus(
    elements: Array<out T>
): List<T>
operator fun <T> Collection<T>.plus(
    elements: Array<out T>
): List<T>

Returns a list containing all elements of the original collection and then all elements of the given elements array.

operator fun <T> Iterable<T>.plus(
    elements: Iterable<T>
): List<T>
operator fun <T> Collection<T>.plus(
    elements: Iterable<T>
): List<T>

Returns a list containing all elements of the original collection and then all elements of the given elements collection.

operator fun <T> Iterable<T>.plus(
    elements: Sequence<T>
): List<T>
operator fun <T> Collection<T>.plus(
    elements: Sequence<T>
): List<T>

Returns a list containing all elements of the original collection and then all elements of the given elements sequence.

operator fun <T> any_array<T>.plus(element: T): Array<T>

Returns an array containing all elements of the original array and then the given element.

operator fun <T> any_array<T>.plus(
    elements: Collection<T>
): Array<T>

Returns an array containing all elements of the original array and then all elements of the given elements collection.

operator fun <T> any_array<T>.plus(
    elements: Array<out T>
): Array<T>

Returns an array containing all elements of the original array and then all elements of the given elements array.

plusAssign

operator fun <T> MutableCollection<in T>.plusAssign(
    element: T)

Adds the specified element to this mutable collection.

operator fun <T> MutableCollection<in T>.plusAssign(
    elements: Iterable<T>)

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

operator fun <T> MutableCollection<in T>.plusAssign(
    elements: Array<T>)

Adds all elements of the given elements array to this mutable collection.

operator fun <T> MutableCollection<in T>.plusAssign(
    elements: Sequence<T>)

Adds all elements of the given elements sequence to this mutable collection.

operator fun <K, V> MutableMap<in K, in V>.plusAssign(
    pair: Pair<K, V>)

Appends or replaces the given pair in this mutable map.

operator fun <K, V> MutableMap<in K, in V>.plusAssign(
    pairs: Iterable<Pair<K, V>>)

Appends or replaces all pairs from the given collection of pairs in this mutable map.

operator fun <K, V> MutableMap<in K, in V>.plusAssign(
    pairs: Array<out Pair<K, V>>)

Appends or replaces all pairs from the given array of pairs in this mutable map.

operator fun <K, V> MutableMap<in K, in V>.plusAssign(
    pairs: Sequence<Pair<K, V>>)

Appends or replaces all pairs from the given sequence of pairs in this mutable map.

operator fun <K, V> MutableMap<in K, in V>.plusAssign(
    map: Map<K, V>)

Appends or replaces all entries from the given map in this mutable map.

plusElement

fun <T> Set<T>.plusElement(element: T): Set<T>

Returns a set containing all elements of the original set and then the given element if it isn't already in this set.

fun <T> Iterable<T>.plusElement(element: T): List<T>
fun <T> Collection<T>.plusElement(element: T): List<T>

Returns a list containing all elements of the original collection and then the given element.

fun <T> Array<T>.plusElement(element: T): Array<T>

Returns an array containing all elements of the original array and then the given element.

putAll

fun <K, V> MutableMap<in K, in V>.putAll(
    pairs: Array<out Pair<K, V>>)

Puts all the given pairs into this MutableMap with the first component in the pair being the key and the second the value.

fun <K, V> MutableMap<in K, in V>.putAll(
    pairs: Iterable<Pair<K, V>>)

Puts all the elements of the given collection into this MutableMap with the first component in the pair being the key and the second the value.

fun <K, V> MutableMap<in K, in V>.putAll(
    pairs: Sequence<Pair<K, V>>)

Puts all the elements of the given sequence into this MutableMap with the first component in the pair being the key and the second the value.

reduce

fun <S, T : S, K> Grouping<T, K>.reduce(
    operation: (key: K, accumulator: S, element: T) -> S
): Map<K, S>

Groups elements from the Grouping source by key and applies the reducing operation to the elements of each group sequentially starting from the second element of the group, 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 first element of the group.

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

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

reduceIndexed

fun <S, T : S> Iterable<T>.reduceIndexed(
    operation: (index: Int, acc: S, T) -> S
): S

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.

fun <S, T : S> any_array<S>.reduceIndexed(
    operation: (index: Int, acc: S, T) -> S
): S

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

reduceRight

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

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

reduceRightIndexed

fun <S, T : S> List<T>.reduceRightIndexed(
    operation: (index: Int, T, acc: S) -> S
): S

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.

fun <S, T : S> any_array<S>.reduceRightIndexed(
    operation: (index: Int, T, acc: S) -> S
): S

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

reduceTo

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

Groups elements from the Grouping source by key and applies the reducing operation to the elements of each group sequentially starting from the second element of the group, 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 first element of the group.

remove

fun <T> MutableCollection<out T>.remove(element: T): Boolean

Removes a single instance of the specified element from this collection, if it is present.

fun <K, V> MutableMap<out K, V>.remove(key: K): V?

Removes the specified key and its corresponding value from this map.

fun <K, V> MutableMap<out K, out V>.remove(
    key: K, 
    value: V
): Boolean

Removes the entry for the specified key only if it is currently mapped to the specified value.

removeAll

fun <T> MutableCollection<out T>.removeAll(
    elements: Collection<T>
): Boolean

Removes all of this collection's elements that are also contained in the specified collection.

fun <T> MutableIterable<T>.removeAll(
    predicate: (T) -> Boolean
): Boolean

Removes all elements from this MutableIterable that match the given predicate.

fun <T> MutableList<T>.removeAll(
    predicate: (T) -> Boolean
): Boolean

Removes all elements from this MutableList that match the given predicate.

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

Removes all elements from this MutableCollection that are also contained in the given elements collection.

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

Removes all elements from this MutableCollection that are also contained in the given elements sequence.

fun <T> MutableCollection<in T>.removeAll(
    elements: Array<out T>
): Boolean

Removes all elements from this MutableCollection that are also contained in the given elements array.

requireNoNulls

fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T>
fun <T : Any> List<T?>.requireNoNulls(): List<T>
fun <T : Any> Array<T?>.requireNoNulls(): Array<T>

Returns an original collection containing all the non-null elements, throwing an IllegalArgumentException if there are any null elements.

retainAll

fun <T> MutableCollection<out T>.retainAll(
    elements: Collection<T>
): Boolean

Retains only the elements in this collection that are contained in the specified collection.

fun <T> MutableIterable<T>.retainAll(
    predicate: (T) -> Boolean
): Boolean

Retains only elements of this MutableIterable that match the given predicate.

fun <T> MutableList<T>.retainAll(
    predicate: (T) -> Boolean
): Boolean

Retains only elements of this MutableList that match the given predicate.

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

Retains only elements of this MutableCollection that are contained in the given elements collection.

fun <T> MutableCollection<in T>.retainAll(
    elements: Array<out T>
): Boolean

Retains only elements of this MutableCollection that are contained in the given elements array.

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

Retains only elements of this MutableCollection that are contained in the given elements sequence.

reverse

fun <T> MutableList<T>.reverse()

Reverses elements in the list in-place.

fun <T> any_array<T>.reverse()

Reverses elements in the array in-place.

reversed

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

Returns a list with elements in reversed order.

reversedArray

fun <T> any_array<T>.reversedArray(): Array<T>

Returns an array with elements of this array in reversed order.

set

operator fun <K, V> MutableMap<K, V>.set(key: K, value: V)

Allows to use the index operator for storing values in a mutable map.

setOf

fun <T> setOf(vararg elements: T): Set<T>

Returns a new read-only set with the given elements. Elements of the set are iterated in the order they were specified. The returned set is serializable (JVM).

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

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

fun <T> setOf(element: T): Set<T>

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

setValue

operator fun <V> MutableMap<in String, in V>.setValue(
    thisRef: Any?, 
    property: KProperty<*>, 
    value: V)

Stores the value of the property for the given object in this mutable map.

single

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

Returns the single element, or throws an exception if the collection is empty or has more than one element.

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

Returns the single element, or throws an exception if the list is empty or has more than one element.

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

Returns the single element matching the given predicate, or throws exception if there is no or more than one matching element.

fun <T> any_array<T>.single(): T

Returns the single element, or throws an exception if the array is empty or has more than one element.

singleOrNull

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

Returns single element, or null if the collection is empty or has more than one element.

fun <T> List<T>.singleOrNull(): T?

Returns single element, or null if the list is empty or has more than one element.

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

Returns the single element matching the given predicate, or null if element was not found or more than one element was found.

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

Returns single element, or null if the array is empty or has more than one element.

slice

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

Returns a list containing elements at indices in the specified indices range.

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

Returns a list containing elements at specified indices.

sliceArray

fun <T> any_array<T>.sliceArray(
    indices: Collection<Int>
): Array<T>

Returns an array containing elements of this array at specified indices.

fun <T> any_array<T>.sliceArray(indices: IntRange): Array<T>

Returns a list containing elements at indices in the specified indices range.

sort

fun <T : Comparable<T>> MutableList<T>.sort()

Sorts elements in the list in-place according to their natural sort order.

fun IntArray.sort()
fun LongArray.sort()
fun ByteArray.sort()
fun ShortArray.sort()
fun DoubleArray.sort()
fun FloatArray.sort()
fun CharArray.sort()

Sorts the array in-place.

fun <T : Comparable<T>> Array<out T>.sort()

Sorts the array in-place according to the natural order of its elements.

fun <T> any_array<T>.sort(
    fromIndex: Int = 0, 
    toIndex: Int = size)

Sorts a range in the array in-place.

fun <T> any_array<T>.sort(comparison: (a: T, b: T) -> Int)

Sorts the array in-place according to the order specified by the given comparison function.

sortBy

fun <T, R : Comparable<R>> MutableList<T>.sortBy(
    selector: (T) -> R?)

Sorts elements in the list in-place according to natural sort order of the value returned by specified selector function.

fun <T, R : Comparable<R>> Array<out T>.sortBy(
    selector: (T) -> R?)

Sorts elements in the array in-place according to natural sort order of the value returned by specified selector function.

sortByDescending

fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(
    selector: (T) -> R?)

Sorts elements in the list in-place descending according to natural sort order of the value returned by specified selector function.

fun <T, R : Comparable<R>> Array<out T>.sortByDescending(
    selector: (T) -> R?)

Sorts elements in the array in-place descending according to natural sort order of the value returned by specified selector function.

sortDescending

fun <T : Comparable<T>> MutableList<T>.sortDescending()

Sorts elements in the list in-place descending according to their natural sort order.

fun <T : Comparable<T>> any_array<T>.sortDescending()

Sorts elements in the array in-place descending according to their natural sort order.

sortWith

fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>)
fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>)

Sorts elements in the list in-place according to the order specified with comparator.

fun <T> any_array<T>.sortWith(comparator: Comparator<in T>)

Sorts the array in-place according to the order specified by the given comparator.

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

Sorts a range in the array in-place with the given comparator.

sorted

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

Returns a list of all elements sorted according to their natural sort order.

sortedArray

fun <T : Comparable<T>> any_array<T>.sortedArray(): Array<T>

Returns an array with all elements of this array sorted according to their natural sort order.

sortedArrayDescending

fun <T : Comparable<T>> any_array<T>.sortedArrayDescending(): Array<T>

Returns an array with all elements of this array sorted descending according to their natural sort order.

sortedArrayWith

fun <T> any_array<T>.sortedArrayWith(
    comparator: Comparator<in T>
): Array<out T>

Returns an array with all elements of this array sorted according the specified comparator.

sortedBy

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

Returns a list of all elements sorted according to natural sort order of the value returned by specified selector function.

sortedByDescending

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

Returns a list of all elements sorted descending according to natural sort order of the value returned by specified selector function.

sortedDescending

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

Returns a list of all elements sorted descending according to their natural sort order.

sortedMapOf

fun <K : Comparable<K>, V> sortedMapOf(
    vararg pairs: Pair<K, V>
): SortedMap<K, V>

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

sortedSetOf

fun <T> sortedSetOf(vararg elements: T): TreeSet<T>

Returns a new SortedSet with the given elements.

fun <T> sortedSetOf(
    comparator: Comparator<in T>, 
    vararg elements: T
): TreeSet<T>

Returns a new SortedSet with the given comparator and elements.

sortedWith

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

Returns a list of all elements sorted according to the specified comparator.

stringMapOf

fun <V> stringMapOf(
    vararg pairs: Pair<String, V>
): HashMap<String, V>

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

stringSetOf

fun stringSetOf(vararg elements: String): HashSet<String>

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

subtract

infix fun <T> Iterable<T>.subtract(
    other: Iterable<T>
): Set<T>

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

infix fun <T> any_array<T>.subtract(
    other: Iterable<T>
): Set<T>

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

sum

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

Returns the sum of all elements in the collection.

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

Returns the sum of all elements in the array.

sumBy

fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int

Returns the sum of all values produced by selector function applied to each element in the collection.

fun <T> any_array<T>.sumBy(selector: (T) -> Int): Int

Returns the sum of all values produced by selector function applied to each element in the array.

sumByDouble

fun <T> Iterable<T>.sumByDouble(
    selector: (T) -> Double
): Double

Returns the sum of all values produced by selector function applied to each element in the collection.

fun <T> any_array<T>.sumByDouble(
    selector: (T) -> Double
): Double

Returns the sum of all values produced by selector function applied to each element in the array.

take

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

Returns a list containing first n elements.

takeLast

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

Returns a list containing last n elements.

takeLastWhile

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

Returns a list containing last elements satisfying the given predicate.

takeWhile

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

Returns a list containing first elements satisfying the given predicate.

toBooleanArray

fun Collection<Boolean>.toBooleanArray(): BooleanArray

Returns an array of Boolean containing all of the elements of this collection.

fun Array<out Boolean>.toBooleanArray(): BooleanArray

Returns an array of Boolean containing all of the elements of this generic array.

toByteArray

fun Collection<Byte>.toByteArray(): ByteArray

Returns an array of Byte containing all of the elements of this collection.

fun Array<out Byte>.toByteArray(): ByteArray

Returns an array of Byte containing all of the elements of this generic array.

toCharArray

fun Collection<Char>.toCharArray(): CharArray

Returns an array of Char containing all of the elements of this collection.

fun Array<out Char>.toCharArray(): CharArray

Returns an array of Char containing all of the elements of this generic array.

toCollection

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

Appends all elements to the given destination collection.

toDoubleArray

fun Collection<Double>.toDoubleArray(): DoubleArray

Returns an array of Double containing all of the elements of this collection.

fun Array<out Double>.toDoubleArray(): DoubleArray

Returns an array of Double containing all of the elements of this generic array.

toFloatArray

fun Collection<Float>.toFloatArray(): FloatArray

Returns an array of Float containing all of the elements of this collection.

fun Array<out Float>.toFloatArray(): FloatArray

Returns an array of Float containing all of the elements of this generic array.

toHashSet

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

Returns a HashSet of all elements.

toIntArray

fun Collection<Int>.toIntArray(): IntArray

Returns an array of Int containing all of the elements of this collection.

fun Array<out Int>.toIntArray(): IntArray

Returns an array of Int containing all of the elements of this generic array.

toList

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

Returns a List containing all elements.

fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>>

Returns a List containing all key-value pairs.

toLongArray

fun Collection<Long>.toLongArray(): LongArray

Returns an array of Long containing all of the elements of this collection.

fun Array<out Long>.toLongArray(): LongArray

Returns an array of Long containing all of the elements of this generic array.

toMap

fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V>

Returns a new map containing all key-value pairs from the given collection of pairs.

fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(
    destination: M
): M

Populates and returns the destination mutable map with key-value pairs from the given collection of pairs.

fun <K, V> Array<out Pair<K, V>>.toMap(): Map<K, V>

Returns a new map containing all key-value pairs from the given array of pairs.

fun <K, V, M : MutableMap<in K, in V>> Array<out Pair<K, V>>.toMap(
    destination: M
): M

Populates and returns the destination mutable map with key-value pairs from the given array of pairs.

fun <K, V> Sequence<Pair<K, V>>.toMap(): Map<K, V>

Returns a new map containing all key-value pairs from the given sequence of pairs.

fun <K, V, M : MutableMap<in K, in V>> Sequence<Pair<K, V>>.toMap(
    destination: M
): M

Populates and returns the destination mutable map with key-value pairs from the given sequence of pairs.

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

Returns a new read-only map containing all key-value pairs from the original map.

fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(
    destination: M
): M

Populates and returns the destination mutable map with key-value pairs from the given map.

toMutableList

fun <T> Iterable<T>.toMutableList(): MutableList<T>
fun <T> Collection<T>.toMutableList(): MutableList<T>

Returns a MutableList filled with all elements of this collection.

fun <T> any_array<T>.toMutableList(): MutableList<T>

Returns a MutableList filled with all elements of this array.

toMutableMap

fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V>

Returns a new mutable map containing all key-value pairs from the original map.

toMutableSet

fun <T> Iterable<T>.toMutableSet(): MutableSet<T>

Returns a mutable set containing all distinct elements from the given collection.

fun <T> any_array<T>.toMutableSet(): MutableSet<T>

Returns a mutable set containing all distinct elements from the given array.

toPair

fun <K, V> Entry<K, V>.toPair(): Pair<K, V>

Converts entry to Pair with key being first component and value being second.

toProperties

fun Map<String, String>.toProperties(): Properties

Converts this Map to a Properties object.

toSet

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

Returns a Set of all elements.

toShortArray

fun Collection<Short>.toShortArray(): ShortArray

Returns an array of Short containing all of the elements of this collection.

fun Array<out Short>.toShortArray(): ShortArray

Returns an array of Short containing all of the elements of this generic array.

toSortedMap

fun <K : Comparable<K>, V> Map<out K, V>.toSortedMap(): SortedMap<K, V>

Converts this Map to a SortedMap so iteration order will be in key order.

fun <K, V> Map<out K, V>.toSortedMap(
    comparator: Comparator<in K>
): SortedMap<K, V>

Converts this Map to a SortedMap using the given comparator so that iteration order will be in the order defined by the comparator.

toSortedSet

fun <T : Comparable<T>> Iterable<T>.toSortedSet(): SortedSet<T>
fun <T> Iterable<T>.toSortedSet(
    comparator: Comparator<in T>
): SortedSet<T>
fun <T : Comparable<T>> Array<out T>.toSortedSet(): SortedSet<T>
fun ByteArray.toSortedSet(): SortedSet<Byte>
fun ShortArray.toSortedSet(): SortedSet<Short>
fun IntArray.toSortedSet(): SortedSet<Int>
fun LongArray.toSortedSet(): SortedSet<Long>
fun FloatArray.toSortedSet(): SortedSet<Float>
fun DoubleArray.toSortedSet(): SortedSet<Double>
fun BooleanArray.toSortedSet(): SortedSet<Boolean>
fun CharArray.toSortedSet(): SortedSet<Char>
fun <T> Array<out T>.toSortedSet(
    comparator: Comparator<in T>
): SortedSet<T>

Returns a SortedSet of all elements.

toString

fun ByteArray.toString(charset: Charset): String

Converts the contents of this byte array to a string using the specified charset.

toTypedArray

fun <T> Collection<T>.toTypedArray(): Array<T>

Returns a typed array containing all of the elements of this collection.

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

Returns a typed object array containing all of the elements of this primitive array.

union

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

Returns a set containing all distinct elements from both collections.

unzip

fun <T, R> Array<out Pair<T, R>>.unzip(): Pair<List<T>, List<R>>

Returns a pair of lists, where first list is built from the first values of each pair from this array, second list is built from the second values of each pair from this array.

fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>>

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.

withDefault

fun <K, V> Map<K, V>.withDefault(
    defaultValue: (key: K) -> V
): Map<K, V>

Returns a wrapper of this read-only map, having the implicit default value provided with the specified function defaultValue.

fun <K, V> MutableMap<K, V>.withDefault(
    defaultValue: (key: K) -> V
): MutableMap<K, V>

Returns a wrapper of this mutable map, having the implicit default value provided with the specified function defaultValue.

withIndex

fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>>

Returns an Iterator wrapping each value produced by this Iterator with the IndexedValue, containing value and it's index.

fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>>

Returns a lazy Iterable of IndexedValue for each element of the original collection.

fun <T> any_array<T>.withIndex(): Iterable<IndexedValue<T>>

Returns a lazy Iterable of IndexedValue for each element of the original array.

zip

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

Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection.

fun <T, R, V> Iterable<T>.zip(
    other: Array<out R>, 
    transform: (a: T, b: R) -> V
): List<V>
fun <T, R, V> Iterable<T>.zip(
    other: Iterable<R>, 
    transform: (a: T, b: R) -> V
): List<V>
fun <T, R, V> Array<out T>.zip(
    other: Array<out R>, 
    transform: (a: T, b: R) -> V
): List<V>
fun <R, V> ByteArray.zip(
    other: Array<out R>, 
    transform: (a: Byte, b: R) -> V
): List<V>
fun <R, V> ShortArray.zip(
    other: Array<out R>, 
    transform: (a: Short, b: R) -> V
): List<V>
fun <R, V> IntArray.zip(
    other: Array<out R>, 
    transform: (a: Int, b: R) -> V
): List<V>
fun <R, V> LongArray.zip(
    other: Array<out R>, 
    transform: (a: Long, b: R) -> V
): List<V>
fun <R, V> FloatArray.zip(
    other: Array<out R>, 
    transform: (a: Float, b: R) -> V
): List<V>
fun <R, V> DoubleArray.zip(
    other: Array<out R>, 
    transform: (a: Double, b: R) -> V
): List<V>
fun <R, V> BooleanArray.zip(
    other: Array<out R>, 
    transform: (a: Boolean, b: R) -> V
): List<V>
fun <R, V> CharArray.zip(
    other: Array<out R>, 
    transform: (a: Char, b: R) -> V
): List<V>
fun <T, R, V> Array<out T>.zip(
    other: Iterable<R>, 
    transform: (a: T, b: R) -> V
): List<V>
fun <R, V> ByteArray.zip(
    other: Iterable<R>, 
    transform: (a: Byte, b: R) -> V
): List<V>
fun <R, V> ShortArray.zip(
    other: Iterable<R>, 
    transform: (a: Short, b: R) -> V
): List<V>
fun <R, V> IntArray.zip(
    other: Iterable<R>, 
    transform: (a: Int, b: R) -> V
): List<V>
fun <R, V> LongArray.zip(
    other: Iterable<R>, 
    transform: (a: Long, b: R) -> V
): List<V>
fun <R, V> FloatArray.zip(
    other: Iterable<R>, 
    transform: (a: Float, b: R) -> V
): List<V>
fun <R, V> DoubleArray.zip(
    other: Iterable<R>, 
    transform: (a: Double, b: R) -> V
): List<V>
fun <R, V> BooleanArray.zip(
    other: Iterable<R>, 
    transform: (a: Boolean, b: R) -> V
): List<V>
fun <R, V> CharArray.zip(
    other: Iterable<R>, 
    transform: (a: Char, b: R) -> V
): List<V>
fun <V> ByteArray.zip(
    other: ByteArray, 
    transform: (a: Byte, b: Byte) -> V
): List<V>
fun <V> ShortArray.zip(
    other: ShortArray, 
    transform: (a: Short, b: Short) -> V
): List<V>
fun <V> IntArray.zip(
    other: IntArray, 
    transform: (a: Int, b: Int) -> V
): List<V>
fun <V> LongArray.zip(
    other: LongArray, 
    transform: (a: Long, b: Long) -> V
): List<V>
fun <V> FloatArray.zip(
    other: FloatArray, 
    transform: (a: Float, b: Float) -> V
): List<V>
fun <V> DoubleArray.zip(
    other: DoubleArray, 
    transform: (a: Double, b: Double) -> V
): List<V>
fun <V> BooleanArray.zip(
    other: BooleanArray, 
    transform: (a: Boolean, b: Boolean) -> V
): List<V>
fun <V> CharArray.zip(
    other: CharArray, 
    transform: (a: Char, b: Char) -> V
): List<V>

Returns a list of values built from elements of both collections with same indexes using provided transform. List has length of shortest collection.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/