Package-level declarations

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

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

Types

Link copied to clipboard
Since Kotlin 1.1
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
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.1
Link copied to clipboard
typealias HashMap<K, V> = java.util.HashMap<K, V>
Since Kotlin 1.1
Link copied to clipboard
Since Kotlin 1.1
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
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.1
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
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.1
Link copied to clipboard
Since Kotlin 1.1
Link copied to clipboard
Since Kotlin 1.1
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
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.1
Link copied to clipboard
interface ListIterator<out T> : Iterator<T>

An iterator over a collection that supports indexed access.

Since Kotlin 1.0
interface ListIterator<out T> : Iterator<T>

An iterator over a collection that supports indexed access.

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

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

Since Kotlin 1.0

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

Since Kotlin 1.1
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
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.1
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
interface MutableIterator<out T> : Iterator<T>

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

Since Kotlin 1.1
Link copied to clipboard

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

Since Kotlin 1.0

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

Since Kotlin 1.1
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

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

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

Functions

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

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

Since Kotlin 1.1
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
fun <T> listOf(element: T): List<T>

Returns an immutable list containing only the specified object element.

Since Kotlin 1.1
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
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.1
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
Since Kotlin 1.1
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 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
Since Kotlin 1.1
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 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
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
fun <T> setOf(element: T): Set<T>

Returns an immutable set containing only the specified object element.

Since Kotlin 1.1
Link copied to clipboard
fun <T> Array<out T>.sort()

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

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)

Sorts a range in the array in-place.

Since Kotlin 1.0
fun <T> Array<out T>.sort(comparison: (a: T, b: T) -> Int)
inline fun ByteArray.sort(noinline comparison: (a: Byte, b: Byte) -> Int)
inline fun CharArray.sort(noinline comparison: (a: Char, b: Char) -> Int)
inline fun DoubleArray.sort(noinline comparison: (a: Double, b: Double) -> Int)
inline fun FloatArray.sort(noinline comparison: (a: Float, b: Float) -> Int)
inline fun IntArray.sort(noinline comparison: (a: Int, b: Int) -> Int)
inline fun LongArray.sort(noinline comparison: (a: Long, b: Long) -> Int)
inline fun ShortArray.sort(noinline comparison: (a: Short, b: Short) -> Int)

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

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

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

Since Kotlin 1.1
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
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