Package-level declarations

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

Types

Link copied to clipboard
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.

Since Kotlin 1.0
Link copied to clipboard
interface Iterable<out T>

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

Since Kotlin 1.0
Link copied to clipboard
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.

Since Kotlin 1.0
Link copied to clipboard
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.

Since Kotlin 1.0
Link copied to clipboard
interface ListIterator<out T> : Iterator<T>

An iterator over a collection that supports indexed access.

Since Kotlin 1.0
Link copied to clipboard
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.

Since Kotlin 1.0
Link copied to clipboard

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

Since Kotlin 1.0
Link copied to clipboard
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.

Since Kotlin 1.0
Link copied to clipboard
interface MutableIterator<out T> : Iterator<T>

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

Since Kotlin 1.0
Link copied to clipboard

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

Since Kotlin 1.0
Link copied to clipboard

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

Since Kotlin 1.0
Link copied to clipboard
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.

Since Kotlin 1.0
Link copied to clipboard
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.

Since Kotlin 1.0
Link copied to clipboard
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.

Since Kotlin 1.0

Functions

Link copied to clipboard
actual fun <T> Array<out T>.asList(): List<T>
actual fun ByteArray.asList(): List<Byte>
actual fun CharArray.asList(): List<Char>
actual fun DoubleArray.asList(): List<Double>
actual fun FloatArray.asList(): List<Float>
actual fun IntArray.asList(): List<Int>
actual fun LongArray.asList(): List<Long>
actual fun ShortArray.asList(): List<Short>

Returns a List that wraps the original array.

Since Kotlin 1.0
Link copied to clipboard
fun <T> Array<out T>.binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size): Int
fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: Int = size): Int
fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size): Int
fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size): Int
fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size): Int
fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size): Int
fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: Int = size): Int
fun ShortArray.binarySearch(element: Short, 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.

Since Kotlin 1.0
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.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun <T> Array<T>.copyOf(): Array<T>
actual inline fun BooleanArray.copyOf(): BooleanArray
actual inline fun ByteArray.copyOf(): ByteArray
actual inline fun CharArray.copyOf(): CharArray
actual inline fun DoubleArray.copyOf(): DoubleArray
actual inline fun FloatArray.copyOf(): FloatArray
actual inline fun IntArray.copyOf(): IntArray
actual inline fun LongArray.copyOf(): LongArray
actual inline fun ShortArray.copyOf(): ShortArray

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

Since Kotlin 1.0
actual inline fun <T> Array<T>.copyOf(newSize: Int): Array<T?>

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

Since Kotlin 1.0
actual inline fun BooleanArray.copyOf(newSize: Int): BooleanArray

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

Since Kotlin 1.0
actual inline fun ByteArray.copyOf(newSize: Int): ByteArray
actual inline fun DoubleArray.copyOf(newSize: Int): DoubleArray
actual inline fun FloatArray.copyOf(newSize: Int): FloatArray
actual inline fun IntArray.copyOf(newSize: Int): IntArray
actual inline fun LongArray.copyOf(newSize: Int): LongArray
actual inline fun ShortArray.copyOf(newSize: Int): ShortArray

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

Since Kotlin 1.0
actual inline fun CharArray.copyOf(newSize: Int): CharArray

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

Since Kotlin 1.0
Link copied to clipboard
@JvmName(name = "copyOfRangeInline")
actual inline fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T>
@JvmName(name = "copyOfRangeInline")
actual inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray
@JvmName(name = "copyOfRangeInline")
actual inline fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray
@JvmName(name = "copyOfRangeInline")
actual inline fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray
@JvmName(name = "copyOfRangeInline")
actual inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray
@JvmName(name = "copyOfRangeInline")
actual inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray
@JvmName(name = "copyOfRangeInline")
actual inline fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray
@JvmName(name = "copyOfRangeInline")
actual inline fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray
@JvmName(name = "copyOfRangeInline")
actual inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray

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

Since Kotlin 1.0
Link copied to clipboard
actual inline fun <T> Array<out T>.elementAt(index: Int): T
actual inline fun BooleanArray.elementAt(index: Int): Boolean
actual inline fun ByteArray.elementAt(index: Int): Byte
actual inline fun CharArray.elementAt(index: Int): Char
actual inline fun DoubleArray.elementAt(index: Int): Double
actual inline fun FloatArray.elementAt(index: Int): Float
actual inline fun IntArray.elementAt(index: Int): Int
actual inline fun LongArray.elementAt(index: Int): Long
actual inline fun ShortArray.elementAt(index: Int): Short

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

Since Kotlin 1.0
Link copied to clipboard
actual fun <T> Array<T>.fill(element: T, fromIndex: Int = 0, toIndex: Int = size)
actual fun BooleanArray.fill(element: Boolean, fromIndex: Int = 0, toIndex: Int = size)
actual fun ByteArray.fill(element: Byte, fromIndex: Int = 0, toIndex: Int = size)
actual fun CharArray.fill(element: Char, fromIndex: Int = 0, toIndex: Int = size)
actual fun DoubleArray.fill(element: Double, fromIndex: Int = 0, toIndex: Int = size)
actual fun FloatArray.fill(element: Float, fromIndex: Int = 0, toIndex: Int = size)
actual fun IntArray.fill(element: Int, fromIndex: Int = 0, toIndex: Int = size)
actual fun LongArray.fill(element: Long, fromIndex: Int = 0, toIndex: Int = size)
actual fun ShortArray.fill(element: Short, fromIndex: Int = 0, toIndex: Int = size)

Fills this array or its subrange with the specified element value.

Since Kotlin 1.0
Link copied to clipboard
fun <R> Array<*>.filterIsInstance(klass: Class<R>): List<R>
fun <R> Iterable<*>.filterIsInstance(klass: Class<R>): List<R>

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

Since Kotlin 1.0
Link copied to clipboard
fun <C : MutableCollection<in R>, R> Array<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C
fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C

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

Since Kotlin 1.0
Link copied to clipboard
inline fun <K, V> ConcurrentMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V

Concurrent getOrPut, that is safe for concurrent maps.

Since Kotlin 1.0
Link copied to clipboard
operator fun <T> Enumeration<T>.iterator(): Iterator<T>

Creates an Iterator for an java.util.Enumeration, allowing to use it in for loops.

Since Kotlin 1.0
Link copied to clipboard
fun <T> listOf(element: T): List<T>

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

Since Kotlin 1.0
Link copied to clipboard
fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V>

Returns an immutable map, mapping only the specified key to the specified value.

Since Kotlin 1.0
Link copied to clipboard
fun <T : Comparable<T>> Array<out T>.max(): T?
fun IntArray.max(): Int?
fun <T : Comparable<T>> Iterable<T>.max(): T?
Since Kotlin 1.0
Link copied to clipboard
inline fun <T, R : Comparable<R>> Array<out T>.maxBy(selector: (T) -> R): T?
inline fun <R : Comparable<R>> BooleanArray.maxBy(selector: (Boolean) -> R): Boolean?
inline fun <R : Comparable<R>> ByteArray.maxBy(selector: (Byte) -> R): Byte?
inline fun <R : Comparable<R>> CharArray.maxBy(selector: (Char) -> R): Char?
inline fun <R : Comparable<R>> DoubleArray.maxBy(selector: (Double) -> R): Double?
inline fun <R : Comparable<R>> FloatArray.maxBy(selector: (Float) -> R): Float?
inline fun <R : Comparable<R>> IntArray.maxBy(selector: (Int) -> R): Int?
inline fun <R : Comparable<R>> LongArray.maxBy(selector: (Long) -> R): Long?
inline fun <R : Comparable<R>> ShortArray.maxBy(selector: (Short) -> R): Short?
inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T) -> R): T?
inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>?
Since Kotlin 1.0
Link copied to clipboard
fun <T> Array<out T>.maxWith(comparator: Comparator<in T>): T?
fun BooleanArray.maxWith(comparator: Comparator<in Boolean>): Boolean?
fun ByteArray.maxWith(comparator: Comparator<in Byte>): Byte?
fun CharArray.maxWith(comparator: Comparator<in Char>): Char?
fun DoubleArray.maxWith(comparator: Comparator<in Double>): Double?
fun FloatArray.maxWith(comparator: Comparator<in Float>): Float?
fun IntArray.maxWith(comparator: Comparator<in Int>): Int?
fun LongArray.maxWith(comparator: Comparator<in Long>): Long?
fun ShortArray.maxWith(comparator: Comparator<in Short>): Short?
fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T?
inline fun <K, V> Map<out K, V>.maxWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>?
Since Kotlin 1.0
Link copied to clipboard
fun <T : Comparable<T>> Array<out T>.min(): T?
fun IntArray.min(): Int?
fun <T : Comparable<T>> Iterable<T>.min(): T?
Since Kotlin 1.0
Link copied to clipboard
inline fun <T, R : Comparable<R>> Array<out T>.minBy(selector: (T) -> R): T?
inline fun <R : Comparable<R>> BooleanArray.minBy(selector: (Boolean) -> R): Boolean?
inline fun <R : Comparable<R>> ByteArray.minBy(selector: (Byte) -> R): Byte?
inline fun <R : Comparable<R>> CharArray.minBy(selector: (Char) -> R): Char?
inline fun <R : Comparable<R>> DoubleArray.minBy(selector: (Double) -> R): Double?
inline fun <R : Comparable<R>> FloatArray.minBy(selector: (Float) -> R): Float?
inline fun <R : Comparable<R>> IntArray.minBy(selector: (Int) -> R): Int?
inline fun <R : Comparable<R>> LongArray.minBy(selector: (Long) -> R): Long?
inline fun <R : Comparable<R>> ShortArray.minBy(selector: (Short) -> R): Short?
inline fun <T, R : Comparable<R>> Iterable<T>.minBy(selector: (T) -> R): T?
inline fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>?
Since Kotlin 1.0
Link copied to clipboard
fun <T> Array<out T>.minWith(comparator: Comparator<in T>): T?
fun BooleanArray.minWith(comparator: Comparator<in Boolean>): Boolean?
fun ByteArray.minWith(comparator: Comparator<in Byte>): Byte?
fun CharArray.minWith(comparator: Comparator<in Char>): Char?
fun DoubleArray.minWith(comparator: Comparator<in Double>): Double?
fun FloatArray.minWith(comparator: Comparator<in Float>): Float?
fun IntArray.minWith(comparator: Comparator<in Int>): Int?
fun LongArray.minWith(comparator: Comparator<in Long>): Long?
fun ShortArray.minWith(comparator: Comparator<in Short>): Short?
fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T?
fun <K, V> Map<out K, V>.minWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>?
Since Kotlin 1.0
Link copied to clipboard
actual inline fun <T> Array<out T>?.orEmpty(): Array<out T>

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

Since Kotlin 1.0
Link copied to clipboard
actual operator fun <T> Array<T>.plus(element: T): Array<T>
actual operator fun BooleanArray.plus(element: Boolean): BooleanArray
actual operator fun ByteArray.plus(element: Byte): ByteArray
actual operator fun CharArray.plus(element: Char): CharArray
actual operator fun DoubleArray.plus(element: Double): DoubleArray
actual operator fun FloatArray.plus(element: Float): FloatArray
actual operator fun IntArray.plus(element: Int): IntArray
actual operator fun LongArray.plus(element: Long): LongArray
actual operator fun ShortArray.plus(element: Short): ShortArray

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

Since Kotlin 1.0
actual operator fun <T> Array<T>.plus(elements: Array<out T>): Array<T>
actual operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray
actual operator fun ByteArray.plus(elements: ByteArray): ByteArray
actual operator fun CharArray.plus(elements: CharArray): CharArray
actual operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray
actual operator fun FloatArray.plus(elements: FloatArray): FloatArray
actual operator fun IntArray.plus(elements: IntArray): IntArray
actual operator fun LongArray.plus(elements: LongArray): LongArray
actual operator fun ShortArray.plus(elements: ShortArray): ShortArray

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

Since Kotlin 1.0
actual operator fun <T> Array<T>.plus(elements: Collection<T>): Array<T>
actual operator fun BooleanArray.plus(elements: Collection<Boolean>): BooleanArray
actual operator fun ByteArray.plus(elements: Collection<Byte>): ByteArray
actual operator fun CharArray.plus(elements: Collection<Char>): CharArray
actual operator fun DoubleArray.plus(elements: Collection<Double>): DoubleArray
actual operator fun FloatArray.plus(elements: Collection<Float>): FloatArray
actual operator fun IntArray.plus(elements: Collection<Int>): IntArray
actual operator fun LongArray.plus(elements: Collection<Long>): LongArray
actual operator fun ShortArray.plus(elements: Collection<Short>): ShortArray

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

Since Kotlin 1.0
Link copied to clipboard
actual inline fun <T> Array<T>.plusElement(element: T): Array<T>

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

Since Kotlin 1.0
Link copied to clipboard
actual fun <T> MutableList<T>.reverse()

Reverses elements in the list in-place.

Since Kotlin 1.0
Link copied to clipboard
fun <T> setOf(element: T): Set<T>

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

Since Kotlin 1.0
Link copied to clipboard
fun <T> Array<out T>.sort()
actual inline fun <T : Comparable<T>> Array<out T>.sort()

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

Since Kotlin 1.0
actual fun ByteArray.sort()
actual fun CharArray.sort()
actual fun DoubleArray.sort()
actual fun FloatArray.sort()
actual fun IntArray.sort()
actual fun LongArray.sort()
actual fun ShortArray.sort()

Sorts the array in-place.

Since Kotlin 1.0
actual fun <T : Comparable<T>> MutableList<T>.sort()

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

Since Kotlin 1.0
inline fun <T> MutableList<T>.sort(comparator: Comparator<in T>)
inline fun <T> MutableList<T>.sort(comparison: (T, T) -> Int)
Since Kotlin 1.0
fun <T> Array<out T>.sort(fromIndex: Int = 0, toIndex: Int = size)
actual fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size)
actual fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size)
actual fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size)
actual fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size)
actual fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size)
actual fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size)
actual fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size)

Sorts a range in the array in-place.

Since Kotlin 1.0
Link copied to clipboard
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.

Since Kotlin 1.0
Link copied to clipboard
fun <T> sortedSetOf(vararg elements: T): TreeSet<T>

Returns a new java.util.SortedSet with the given elements.

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

Returns a new java.util.SortedSet with the given comparator and elements.

Since Kotlin 1.0
Link copied to clipboard
actual fun <T> Array<out T>.sortWith(comparator: Comparator<in T>)

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

Since Kotlin 1.0
actual fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>)

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

Since Kotlin 1.0
actual 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.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T> Enumeration<T>.toList(): List<T>

Returns a list containing the elements returned by this enumeration in the order they are returned by the enumeration.

Since Kotlin 1.0
Link copied to clipboard

Converts this Map to a Properties object.

Since Kotlin 1.0
Link copied to clipboard
fun <K : Comparable<K>, V> Map<out K, V>.toSortedMap(): SortedMap<K, V>

Converts this Map to a SortedMap. The resulting SortedMap determines the equality and order of keys according to their natural sorting order.

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

Converts this Map to a SortedMap. The resulting SortedMap determines the equality and order of keys according to the sorting order provided by the given comparator.

Since Kotlin 1.0
Link copied to clipboard
Link copied to clipboard
inline fun ByteArray.toString(charset: Charset): String

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

Since Kotlin 1.0
Link copied to clipboard

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

Since Kotlin 1.0
actual inline fun <T> Collection<T>.toTypedArray(): Array<T>

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

Since Kotlin 1.0