diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 8d13a517be9..e7be3162e5a 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -5633,93 +5633,93 @@ public fun ShortArray.toArrayList(): ArrayList { } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > Array.toCollection(collection: C): C { +public fun > Array.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > BooleanArray.toCollection(collection: C): C { +public fun > BooleanArray.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > ByteArray.toCollection(collection: C): C { +public fun > ByteArray.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > CharArray.toCollection(collection: C): C { +public fun > CharArray.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > DoubleArray.toCollection(collection: C): C { +public fun > DoubleArray.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > FloatArray.toCollection(collection: C): C { +public fun > FloatArray.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > IntArray.toCollection(collection: C): C { +public fun > IntArray.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > LongArray.toCollection(collection: C): C { +public fun > LongArray.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > ShortArray.toCollection(collection: C): C { +public fun > ShortArray.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** @@ -6497,74 +6497,74 @@ public inline fun > ShortArray.flatMapTo(destinat } /** - * Returns a map of the elements in original array grouped by the result of given [toKey] function. + * Returns a map of the elements in original array grouped by the key returned by the given [selector] function. */ -public inline fun Array.groupBy(toKey: (T) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun Array.groupBy(selector: (T) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Returns a map of the elements in original array grouped by the result of given [toKey] function. + * Returns a map of the elements in original array grouped by the key returned by the given [selector] function. */ -public inline fun BooleanArray.groupBy(toKey: (Boolean) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun BooleanArray.groupBy(selector: (Boolean) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Returns a map of the elements in original array grouped by the result of given [toKey] function. + * Returns a map of the elements in original array grouped by the key returned by the given [selector] function. */ -public inline fun ByteArray.groupBy(toKey: (Byte) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun ByteArray.groupBy(selector: (Byte) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Returns a map of the elements in original array grouped by the result of given [toKey] function. + * Returns a map of the elements in original array grouped by the key returned by the given [selector] function. */ -public inline fun CharArray.groupBy(toKey: (Char) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun CharArray.groupBy(selector: (Char) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Returns a map of the elements in original array grouped by the result of given [toKey] function. + * Returns a map of the elements in original array grouped by the key returned by the given [selector] function. */ -public inline fun DoubleArray.groupBy(toKey: (Double) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun DoubleArray.groupBy(selector: (Double) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Returns a map of the elements in original array grouped by the result of given [toKey] function. + * Returns a map of the elements in original array grouped by the key returned by the given [selector] function. */ -public inline fun FloatArray.groupBy(toKey: (Float) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun FloatArray.groupBy(selector: (Float) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Returns a map of the elements in original array grouped by the result of given [toKey] function. + * Returns a map of the elements in original array grouped by the key returned by the given [selector] function. */ -public inline fun IntArray.groupBy(toKey: (Int) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun IntArray.groupBy(selector: (Int) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Returns a map of the elements in original array grouped by the result of given [toKey] function. + * Returns a map of the elements in original array grouped by the key returned by the given [selector] function. */ -public inline fun LongArray.groupBy(toKey: (Long) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun LongArray.groupBy(selector: (Long) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Returns a map of the elements in original array grouped by the result of given [toKey] function. + * Returns a map of the elements in original array grouped by the key returned by the given [selector] function. */ -public inline fun ShortArray.groupBy(toKey: (Short) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun ShortArray.groupBy(selector: (Short) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Appends elements from original array grouped by the result of given [toKey] function to the given [map]. + * Appends elements from original array grouped by the key returned by the given [selector] function to the given [map]. */ -public inline fun Array.groupByTo(map: MutableMap>, toKey: (T) -> K): Map> { +public inline fun Array.groupByTo(map: MutableMap>, selector: (T) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -6572,11 +6572,11 @@ public inline fun Array.groupByTo(map: MutableMap BooleanArray.groupByTo(map: MutableMap>, toKey: (Boolean) -> K): Map> { +public inline fun BooleanArray.groupByTo(map: MutableMap>, selector: (Boolean) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -6584,11 +6584,11 @@ public inline fun BooleanArray.groupByTo(map: MutableMap ByteArray.groupByTo(map: MutableMap>, toKey: (Byte) -> K): Map> { +public inline fun ByteArray.groupByTo(map: MutableMap>, selector: (Byte) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -6596,11 +6596,11 @@ public inline fun ByteArray.groupByTo(map: MutableMap>, } /** - * Appends elements from original array grouped by the result of given [toKey] function to the given [map]. + * Appends elements from original array grouped by the key returned by the given [selector] function to the given [map]. */ -public inline fun CharArray.groupByTo(map: MutableMap>, toKey: (Char) -> K): Map> { +public inline fun CharArray.groupByTo(map: MutableMap>, selector: (Char) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -6608,11 +6608,11 @@ public inline fun CharArray.groupByTo(map: MutableMap>, } /** - * Appends elements from original array grouped by the result of given [toKey] function to the given [map]. + * Appends elements from original array grouped by the key returned by the given [selector] function to the given [map]. */ -public inline fun DoubleArray.groupByTo(map: MutableMap>, toKey: (Double) -> K): Map> { +public inline fun DoubleArray.groupByTo(map: MutableMap>, selector: (Double) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -6620,11 +6620,11 @@ public inline fun DoubleArray.groupByTo(map: MutableMap FloatArray.groupByTo(map: MutableMap>, toKey: (Float) -> K): Map> { +public inline fun FloatArray.groupByTo(map: MutableMap>, selector: (Float) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -6632,11 +6632,11 @@ public inline fun FloatArray.groupByTo(map: MutableMap } /** - * Appends elements from original array grouped by the result of given [toKey] function to the given [map]. + * Appends elements from original array grouped by the key returned by the given [selector] function to the given [map]. */ -public inline fun IntArray.groupByTo(map: MutableMap>, toKey: (Int) -> K): Map> { +public inline fun IntArray.groupByTo(map: MutableMap>, selector: (Int) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -6644,11 +6644,11 @@ public inline fun IntArray.groupByTo(map: MutableMap>, t } /** - * Appends elements from original array grouped by the result of given [toKey] function to the given [map]. + * Appends elements from original array grouped by the key returned by the given [selector] function to the given [map]. */ -public inline fun LongArray.groupByTo(map: MutableMap>, toKey: (Long) -> K): Map> { +public inline fun LongArray.groupByTo(map: MutableMap>, selector: (Long) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -6656,11 +6656,11 @@ public inline fun LongArray.groupByTo(map: MutableMap>, } /** - * Appends elements from original array grouped by the result of given [toKey] function to the given [map]. + * Appends elements from original array grouped by the key returned by the given [selector] function to the given [map]. */ -public inline fun ShortArray.groupByTo(map: MutableMap>, toKey: (Short) -> K): Map> { +public inline fun ShortArray.groupByTo(map: MutableMap>, selector: (Short) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -7170,14 +7170,15 @@ public fun ShortArray.distinct(): List { } /** - * Returns a list containing only distinct elements from the given array according to the [keySelector]. + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source array. */ -public inline fun Array.distinctBy(keySelector: (T) -> K): List { +public inline fun Array.distinctBy(selector: (T) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -7185,14 +7186,15 @@ public inline fun Array.distinctBy(keySelector: (T) -> K): List } /** - * Returns a list containing only distinct elements from the given array according to the [keySelector]. + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source array. */ -public inline fun BooleanArray.distinctBy(keySelector: (Boolean) -> K): List { +public inline fun BooleanArray.distinctBy(selector: (Boolean) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -7200,14 +7202,15 @@ public inline fun BooleanArray.distinctBy(keySelector: (Boolean) -> K): List } /** - * Returns a list containing only distinct elements from the given array according to the [keySelector]. + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source array. */ -public inline fun ByteArray.distinctBy(keySelector: (Byte) -> K): List { +public inline fun ByteArray.distinctBy(selector: (Byte) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -7215,14 +7218,15 @@ public inline fun ByteArray.distinctBy(keySelector: (Byte) -> K): List } /** - * Returns a list containing only distinct elements from the given array according to the [keySelector]. + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source array. */ -public inline fun CharArray.distinctBy(keySelector: (Char) -> K): List { +public inline fun CharArray.distinctBy(selector: (Char) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -7230,14 +7234,15 @@ public inline fun CharArray.distinctBy(keySelector: (Char) -> K): List } /** - * Returns a list containing only distinct elements from the given array according to the [keySelector]. + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source array. */ -public inline fun DoubleArray.distinctBy(keySelector: (Double) -> K): List { +public inline fun DoubleArray.distinctBy(selector: (Double) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -7245,14 +7250,15 @@ public inline fun DoubleArray.distinctBy(keySelector: (Double) -> K): List FloatArray.distinctBy(keySelector: (Float) -> K): List { +public inline fun FloatArray.distinctBy(selector: (Float) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -7260,14 +7266,15 @@ public inline fun FloatArray.distinctBy(keySelector: (Float) -> K): List IntArray.distinctBy(keySelector: (Int) -> K): List { +public inline fun IntArray.distinctBy(selector: (Int) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -7275,14 +7282,15 @@ public inline fun IntArray.distinctBy(keySelector: (Int) -> K): List { } /** - * Returns a list containing only distinct elements from the given array according to the [keySelector]. + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source array. */ -public inline fun LongArray.distinctBy(keySelector: (Long) -> K): List { +public inline fun LongArray.distinctBy(selector: (Long) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -7290,14 +7298,15 @@ public inline fun LongArray.distinctBy(keySelector: (Long) -> K): List } /** - * Returns a list containing only distinct elements from the given array according to the [keySelector]. + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source array. */ -public inline fun ShortArray.distinctBy(keySelector: (Short) -> K): List { +public inline fun ShortArray.distinctBy(selector: (Short) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -8178,138 +8187,138 @@ public inline fun ShortArray.foldRight(initial: R, operation: (Short, R) -> } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun Array.forEach(operation: (T) -> Unit): Unit { - for (element in this) operation(element) +public inline fun Array.forEach(action: (T) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun BooleanArray.forEach(operation: (Boolean) -> Unit): Unit { - for (element in this) operation(element) +public inline fun BooleanArray.forEach(action: (Boolean) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun ByteArray.forEach(operation: (Byte) -> Unit): Unit { - for (element in this) operation(element) +public inline fun ByteArray.forEach(action: (Byte) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun CharArray.forEach(operation: (Char) -> Unit): Unit { - for (element in this) operation(element) +public inline fun CharArray.forEach(action: (Char) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun DoubleArray.forEach(operation: (Double) -> Unit): Unit { - for (element in this) operation(element) +public inline fun DoubleArray.forEach(action: (Double) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun FloatArray.forEach(operation: (Float) -> Unit): Unit { - for (element in this) operation(element) +public inline fun FloatArray.forEach(action: (Float) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun IntArray.forEach(operation: (Int) -> Unit): Unit { - for (element in this) operation(element) +public inline fun IntArray.forEach(action: (Int) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun LongArray.forEach(operation: (Long) -> Unit): Unit { - for (element in this) operation(element) +public inline fun LongArray.forEach(action: (Long) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun ShortArray.forEach(operation: (Short) -> Unit): Unit { - for (element in this) operation(element) +public inline fun ShortArray.forEach(action: (Short) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun Array.forEachIndexed(operation: (Int, T) -> Unit): Unit { +public inline fun Array.forEachIndexed(action: (Int, T) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun BooleanArray.forEachIndexed(operation: (Int, Boolean) -> Unit): Unit { +public inline fun BooleanArray.forEachIndexed(action: (Int, Boolean) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun ByteArray.forEachIndexed(operation: (Int, Byte) -> Unit): Unit { +public inline fun ByteArray.forEachIndexed(action: (Int, Byte) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun CharArray.forEachIndexed(operation: (Int, Char) -> Unit): Unit { +public inline fun CharArray.forEachIndexed(action: (Int, Char) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun DoubleArray.forEachIndexed(operation: (Int, Double) -> Unit): Unit { +public inline fun DoubleArray.forEachIndexed(action: (Int, Double) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun FloatArray.forEachIndexed(operation: (Int, Float) -> Unit): Unit { +public inline fun FloatArray.forEachIndexed(action: (Int, Float) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun IntArray.forEachIndexed(operation: (Int, Int) -> Unit): Unit { +public inline fun IntArray.forEachIndexed(action: (Int, Int) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun LongArray.forEachIndexed(operation: (Int, Long) -> Unit): Unit { +public inline fun LongArray.forEachIndexed(action: (Int, Long) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun ShortArray.forEachIndexed(operation: (Int, Short) -> Unit): Unit { +public inline fun ShortArray.forEachIndexed(action: (Int, Short) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** @@ -8419,13 +8428,13 @@ public fun ShortArray.max(): Short? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Array.maxBy(f: (T) -> R): T? { +public inline fun , T : Any> Array.maxBy(selector: (T) -> R): T? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -8437,13 +8446,13 @@ public inline fun , T : Any> Array.maxBy(f: (T) -> R): /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > BooleanArray.maxBy(f: (Boolean) -> R): Boolean? { +public inline fun > BooleanArray.maxBy(selector: (Boolean) -> R): Boolean? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -8455,13 +8464,13 @@ public inline fun > BooleanArray.maxBy(f: (Boolean) -> R): Boo /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > ByteArray.maxBy(f: (Byte) -> R): Byte? { +public inline fun > ByteArray.maxBy(selector: (Byte) -> R): Byte? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -8473,13 +8482,13 @@ public inline fun > ByteArray.maxBy(f: (Byte) -> R): Byte? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > CharArray.maxBy(f: (Char) -> R): Char? { +public inline fun > CharArray.maxBy(selector: (Char) -> R): Char? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -8491,13 +8500,13 @@ public inline fun > CharArray.maxBy(f: (Char) -> R): Char? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > DoubleArray.maxBy(f: (Double) -> R): Double? { +public inline fun > DoubleArray.maxBy(selector: (Double) -> R): Double? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -8509,13 +8518,13 @@ public inline fun > DoubleArray.maxBy(f: (Double) -> R): Doubl /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > FloatArray.maxBy(f: (Float) -> R): Float? { +public inline fun > FloatArray.maxBy(selector: (Float) -> R): Float? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -8527,13 +8536,13 @@ public inline fun > FloatArray.maxBy(f: (Float) -> R): Float? /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > IntArray.maxBy(f: (Int) -> R): Int? { +public inline fun > IntArray.maxBy(selector: (Int) -> R): Int? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -8545,13 +8554,13 @@ public inline fun > IntArray.maxBy(f: (Int) -> R): Int? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > LongArray.maxBy(f: (Long) -> R): Long? { +public inline fun > LongArray.maxBy(selector: (Long) -> R): Long? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -8563,13 +8572,13 @@ public inline fun > LongArray.maxBy(f: (Long) -> R): Long? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > ShortArray.maxBy(f: (Short) -> R): Short? { +public inline fun > ShortArray.maxBy(selector: (Short) -> R): Short? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -8685,13 +8694,13 @@ public fun ShortArray.min(): Short? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Array.minBy(f: (T) -> R): T? { +public inline fun , T : Any> Array.minBy(selector: (T) -> R): T? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -8703,13 +8712,13 @@ public inline fun , T : Any> Array.minBy(f: (T) -> R): /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > BooleanArray.minBy(f: (Boolean) -> R): Boolean? { +public inline fun > BooleanArray.minBy(selector: (Boolean) -> R): Boolean? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -8721,13 +8730,13 @@ public inline fun > BooleanArray.minBy(f: (Boolean) -> R): Boo /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > ByteArray.minBy(f: (Byte) -> R): Byte? { +public inline fun > ByteArray.minBy(selector: (Byte) -> R): Byte? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -8739,13 +8748,13 @@ public inline fun > ByteArray.minBy(f: (Byte) -> R): Byte? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > CharArray.minBy(f: (Char) -> R): Char? { +public inline fun > CharArray.minBy(selector: (Char) -> R): Char? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -8757,13 +8766,13 @@ public inline fun > CharArray.minBy(f: (Char) -> R): Char? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > DoubleArray.minBy(f: (Double) -> R): Double? { +public inline fun > DoubleArray.minBy(selector: (Double) -> R): Double? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -8775,13 +8784,13 @@ public inline fun > DoubleArray.minBy(f: (Double) -> R): Doubl /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > FloatArray.minBy(f: (Float) -> R): Float? { +public inline fun > FloatArray.minBy(selector: (Float) -> R): Float? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -8793,13 +8802,13 @@ public inline fun > FloatArray.minBy(f: (Float) -> R): Float? /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > IntArray.minBy(f: (Int) -> R): Int? { +public inline fun > IntArray.minBy(selector: (Int) -> R): Int? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -8811,13 +8820,13 @@ public inline fun > IntArray.minBy(f: (Int) -> R): Int? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > LongArray.minBy(f: (Long) -> R): Long? { +public inline fun > LongArray.minBy(selector: (Long) -> R): Long? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -8829,13 +8838,13 @@ public inline fun > LongArray.minBy(f: (Long) -> R): Long? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > ShortArray.minBy(f: (Short) -> R): Short? { +public inline fun > ShortArray.minBy(selector: (Short) -> R): Short? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -9223,199 +9232,199 @@ public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Sh } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun Array.sumBy(transform: (T) -> Int): Int { +public inline fun Array.sumBy(selector: (T) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun BooleanArray.sumBy(transform: (Boolean) -> Int): Int { +public inline fun BooleanArray.sumBy(selector: (Boolean) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun ByteArray.sumBy(transform: (Byte) -> Int): Int { +public inline fun ByteArray.sumBy(selector: (Byte) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun CharArray.sumBy(transform: (Char) -> Int): Int { +public inline fun CharArray.sumBy(selector: (Char) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun DoubleArray.sumBy(transform: (Double) -> Int): Int { +public inline fun DoubleArray.sumBy(selector: (Double) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun FloatArray.sumBy(transform: (Float) -> Int): Int { +public inline fun FloatArray.sumBy(selector: (Float) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun IntArray.sumBy(transform: (Int) -> Int): Int { +public inline fun IntArray.sumBy(selector: (Int) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun LongArray.sumBy(transform: (Long) -> Int): Int { +public inline fun LongArray.sumBy(selector: (Long) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun ShortArray.sumBy(transform: (Short) -> Int): Int { +public inline fun ShortArray.sumBy(selector: (Short) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun Array.sumByDouble(transform: (T) -> Double): Double { +public inline fun Array.sumByDouble(selector: (T) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun BooleanArray.sumByDouble(transform: (Boolean) -> Double): Double { +public inline fun BooleanArray.sumByDouble(selector: (Boolean) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun ByteArray.sumByDouble(transform: (Byte) -> Double): Double { +public inline fun ByteArray.sumByDouble(selector: (Byte) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun CharArray.sumByDouble(transform: (Char) -> Double): Double { +public inline fun CharArray.sumByDouble(selector: (Char) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun DoubleArray.sumByDouble(transform: (Double) -> Double): Double { +public inline fun DoubleArray.sumByDouble(selector: (Double) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun FloatArray.sumByDouble(transform: (Float) -> Double): Double { +public inline fun FloatArray.sumByDouble(selector: (Float) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun IntArray.sumByDouble(transform: (Int) -> Double): Double { +public inline fun IntArray.sumByDouble(selector: (Int) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun LongArray.sumByDouble(transform: (Long) -> Double): Double { +public inline fun LongArray.sumByDouble(selector: (Long) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the array. + * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun ShortArray.sumByDouble(transform: (Short) -> Double): Double { +public inline fun ShortArray.sumByDouble(selector: (Short) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } @@ -9597,74 +9606,74 @@ public inline fun ShortArray.partition(predicate: (Short) -> Boolean): Pair Array.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun Array.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun BooleanArray.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun BooleanArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun ByteArray.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun ByteArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun CharArray.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun CharArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun DoubleArray.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun DoubleArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun FloatArray.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun FloatArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun IntArray.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun IntArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun LongArray.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun LongArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun ShortArray.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun ShortArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun Array.zip(array: Array, transform: (T, R) -> V): List { - val size = Math.min(size, array.size) +public inline fun Array.zip(other: Array, transform: (T, R) -> V): List { + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list } @@ -9672,11 +9681,11 @@ public inline fun Array.zip(array: Array, transform: (T, /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun BooleanArray.zip(array: Array, transform: (Boolean, R) -> V): List { - val size = Math.min(size, array.size) +public inline fun BooleanArray.zip(other: Array, transform: (Boolean, R) -> V): List { + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list } @@ -9684,11 +9693,11 @@ public inline fun BooleanArray.zip(array: Array, transform: (Boole /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun ByteArray.zip(array: Array, transform: (Byte, R) -> V): List { - val size = Math.min(size, array.size) +public inline fun ByteArray.zip(other: Array, transform: (Byte, R) -> V): List { + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list } @@ -9696,11 +9705,11 @@ public inline fun ByteArray.zip(array: Array, transform: (Byte, R) /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun CharArray.zip(array: Array, transform: (Char, R) -> V): List { - val size = Math.min(size, array.size) +public inline fun CharArray.zip(other: Array, transform: (Char, R) -> V): List { + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list } @@ -9708,11 +9717,11 @@ public inline fun CharArray.zip(array: Array, transform: (Char, R) /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun DoubleArray.zip(array: Array, transform: (Double, R) -> V): List { - val size = Math.min(size, array.size) +public inline fun DoubleArray.zip(other: Array, transform: (Double, R) -> V): List { + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list } @@ -9720,11 +9729,11 @@ public inline fun DoubleArray.zip(array: Array, transform: (Double /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun FloatArray.zip(array: Array, transform: (Float, R) -> V): List { - val size = Math.min(size, array.size) +public inline fun FloatArray.zip(other: Array, transform: (Float, R) -> V): List { + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list } @@ -9732,11 +9741,11 @@ public inline fun FloatArray.zip(array: Array, transform: (Float, /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun IntArray.zip(array: Array, transform: (Int, R) -> V): List { - val size = Math.min(size, array.size) +public inline fun IntArray.zip(other: Array, transform: (Int, R) -> V): List { + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list } @@ -9744,11 +9753,11 @@ public inline fun IntArray.zip(array: Array, transform: (Int, R) - /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun LongArray.zip(array: Array, transform: (Long, R) -> V): List { - val size = Math.min(size, array.size) +public inline fun LongArray.zip(other: Array, transform: (Long, R) -> V): List { + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list } @@ -9756,163 +9765,11 @@ public inline fun LongArray.zip(array: Array, transform: (Long, R) /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun ShortArray.zip(array: Array, transform: (Short, R) -> V): List { - val size = Math.min(size, array.size) +public inline fun ShortArray.zip(other: Array, transform: (Short, R) -> V): List { + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) - } - return list -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun BooleanArray.zip(array: BooleanArray): List> { - return zip(array) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun ByteArray.zip(array: ByteArray): List> { - return zip(array) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun CharArray.zip(array: CharArray): List> { - return zip(array) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun DoubleArray.zip(array: DoubleArray): List> { - return zip(array) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun FloatArray.zip(array: FloatArray): List> { - return zip(array) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun IntArray.zip(array: IntArray): List> { - return zip(array) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun LongArray.zip(array: LongArray): List> { - return zip(array) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun ShortArray.zip(array: ShortArray): List> { - return zip(array) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun BooleanArray.zip(array: BooleanArray, transform: (Boolean, Boolean) -> V): List { - val size = Math.min(size, array.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], array[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun ByteArray.zip(array: ByteArray, transform: (Byte, Byte) -> V): List { - val size = Math.min(size, array.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], array[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun CharArray.zip(array: CharArray, transform: (Char, Char) -> V): List { - val size = Math.min(size, array.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], array[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun DoubleArray.zip(array: DoubleArray, transform: (Double, Double) -> V): List { - val size = Math.min(size, array.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], array[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun FloatArray.zip(array: FloatArray, transform: (Float, Float) -> V): List { - val size = Math.min(size, array.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], array[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun IntArray.zip(array: IntArray, transform: (Int, Int) -> V): List { - val size = Math.min(size, array.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], array[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun LongArray.zip(array: LongArray, transform: (Long, Long) -> V): List { - val size = Math.min(size, array.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], array[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun ShortArray.zip(array: ShortArray, transform: (Short, Short) -> V): List { - val size = Math.min(size, array.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list } @@ -10106,6 +9963,158 @@ public inline fun ShortArray.zip(other: Iterable, transform: (Short, R return list } +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun BooleanArray.zip(other: BooleanArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun ByteArray.zip(other: ByteArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun CharArray.zip(other: CharArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun DoubleArray.zip(other: DoubleArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun FloatArray.zip(other: FloatArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun IntArray.zip(other: IntArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun LongArray.zip(other: LongArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun ShortArray.zip(other: ShortArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun BooleanArray.zip(other: BooleanArray, transform: (Boolean, Boolean) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun ByteArray.zip(other: ByteArray, transform: (Byte, Byte) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun CharArray.zip(other: CharArray, transform: (Char, Char) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun DoubleArray.zip(other: DoubleArray, transform: (Double, Double) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun FloatArray.zip(other: FloatArray, transform: (Float, Float) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun IntArray.zip(other: IntArray, transform: (Int, Int) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun LongArray.zip(other: LongArray, transform: (Long, Long) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun ShortArray.zip(other: ShortArray, transform: (Short, Short) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + /** * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] @@ -10599,10 +10608,10 @@ public fun BooleanArray.asList(): List { return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(o: Boolean): Boolean = this@asList.contains(o) + override fun contains(element: Boolean): Boolean = this@asList.contains(element) override fun get(index: Int): Boolean = this@asList[index] - override fun indexOf(o: Boolean): Int = this@asList.indexOf(o) - override fun lastIndexOf(o: Boolean): Int = this@asList.lastIndexOf(o) + override fun indexOf(element: Boolean): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Boolean): Int = this@asList.lastIndexOf(element) } } @@ -10614,10 +10623,10 @@ public fun ByteArray.asList(): List { return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(o: Byte): Boolean = this@asList.contains(o) + override fun contains(element: Byte): Boolean = this@asList.contains(element) override fun get(index: Int): Byte = this@asList[index] - override fun indexOf(o: Byte): Int = this@asList.indexOf(o) - override fun lastIndexOf(o: Byte): Int = this@asList.lastIndexOf(o) + override fun indexOf(element: Byte): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Byte): Int = this@asList.lastIndexOf(element) } } @@ -10629,10 +10638,10 @@ public fun CharArray.asList(): List { return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(o: Char): Boolean = this@asList.contains(o) + override fun contains(element: Char): Boolean = this@asList.contains(element) override fun get(index: Int): Char = this@asList[index] - override fun indexOf(o: Char): Int = this@asList.indexOf(o) - override fun lastIndexOf(o: Char): Int = this@asList.lastIndexOf(o) + override fun indexOf(element: Char): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Char): Int = this@asList.lastIndexOf(element) } } @@ -10644,10 +10653,10 @@ public fun DoubleArray.asList(): List { return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(o: Double): Boolean = this@asList.contains(o) + override fun contains(element: Double): Boolean = this@asList.contains(element) override fun get(index: Int): Double = this@asList[index] - override fun indexOf(o: Double): Int = this@asList.indexOf(o) - override fun lastIndexOf(o: Double): Int = this@asList.lastIndexOf(o) + override fun indexOf(element: Double): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Double): Int = this@asList.lastIndexOf(element) } } @@ -10659,10 +10668,10 @@ public fun FloatArray.asList(): List { return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(o: Float): Boolean = this@asList.contains(o) + override fun contains(element: Float): Boolean = this@asList.contains(element) override fun get(index: Int): Float = this@asList[index] - override fun indexOf(o: Float): Int = this@asList.indexOf(o) - override fun lastIndexOf(o: Float): Int = this@asList.lastIndexOf(o) + override fun indexOf(element: Float): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Float): Int = this@asList.lastIndexOf(element) } } @@ -10674,10 +10683,10 @@ public fun IntArray.asList(): List { return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(o: Int): Boolean = this@asList.contains(o) + override fun contains(element: Int): Boolean = this@asList.contains(element) override fun get(index: Int): Int = this@asList[index] - override fun indexOf(o: Int): Int = this@asList.indexOf(o) - override fun lastIndexOf(o: Int): Int = this@asList.lastIndexOf(o) + override fun indexOf(element: Int): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Int): Int = this@asList.lastIndexOf(element) } } @@ -10689,10 +10698,10 @@ public fun LongArray.asList(): List { return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(o: Long): Boolean = this@asList.contains(o) + override fun contains(element: Long): Boolean = this@asList.contains(element) override fun get(index: Int): Long = this@asList[index] - override fun indexOf(o: Long): Int = this@asList.indexOf(o) - override fun lastIndexOf(o: Long): Int = this@asList.lastIndexOf(o) + override fun indexOf(element: Long): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Long): Int = this@asList.lastIndexOf(element) } } @@ -10704,10 +10713,10 @@ public fun ShortArray.asList(): List { return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(o: Short): Boolean = this@asList.contains(o) + override fun contains(element: Short): Boolean = this@asList.contains(element) override fun get(index: Int): Short = this@asList[index] - override fun indexOf(o: Short): Int = this@asList.indexOf(o) - override fun lastIndexOf(o: Short): Int = this@asList.lastIndexOf(o) + override fun indexOf(element: Short): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Short): Int = this@asList.lastIndexOf(element) } } diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index 6b6a6d19d6c..f3f66782237 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -992,13 +992,13 @@ public fun Iterable.toArrayList(): ArrayList { } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > Iterable.toCollection(collection: C): C { +public fun > Iterable.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** @@ -1088,18 +1088,18 @@ public inline fun > Iterable.flatMapTo(dest } /** - * Returns a map of the elements in original collection grouped by the result of given [toKey] function. + * Returns a map of the elements in original collection grouped by the key returned by the given [selector] function. */ -public inline fun Iterable.groupBy(toKey: (T) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun Iterable.groupBy(selector: (T) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Appends elements from original collection grouped by the result of given [toKey] function to the given [map]. + * Appends elements from original collection grouped by the key returned by the given [selector] function to the given [map]. */ -public inline fun Iterable.groupByTo(map: MutableMap>, toKey: (T) -> K): Map> { +public inline fun Iterable.groupByTo(map: MutableMap>, selector: (T) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -1193,14 +1193,15 @@ public fun Iterable.distinct(): List { } /** - * Returns a list containing only distinct elements from the given collection according to the [keySelector]. + * Returns a list containing only elements from the given collection + * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source collection. */ -public inline fun Iterable.distinctBy(keySelector: (T) -> K): List { +public inline fun Iterable.distinctBy(selector: (T) -> K): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -1315,18 +1316,18 @@ public inline fun List.foldRight(initial: R, operation: (T, R) -> R): } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun Iterable.forEach(operation: (T) -> Unit): Unit { - for (element in this) operation(element) +public inline fun Iterable.forEach(action: (T) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun Iterable.forEachIndexed(operation: (Int, T) -> Unit): Unit { +public inline fun Iterable.forEachIndexed(action: (Int, T) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** @@ -1346,14 +1347,14 @@ public fun > Iterable.max(): T? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Iterable.maxBy(f: (T) -> R): T? { +public inline fun , T : Any> Iterable.maxBy(selector: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null var maxElem = iterator.next() - var maxValue = f(maxElem) + var maxValue = selector(maxElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -1379,14 +1380,14 @@ public fun > Iterable.min(): T? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Iterable.minBy(f: (T) -> R): T? { +public inline fun , T : Any> Iterable.minBy(selector: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null var minElem = iterator.next() - var minValue = f(minElem) + var minValue = selector(minElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -1438,23 +1439,23 @@ public inline fun List.reduceRight(operation: (T, S) -> S): S { } /** - * Returns the sum of all values produced by [transform] function applied to each element in the collection. + * Returns the sum of all values produced by [selector] function applied to each element in the collection. */ -public inline fun Iterable.sumBy(transform: (T) -> Int): Int { +public inline fun Iterable.sumBy(selector: (T) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the collection. + * Returns the sum of all values produced by [selector] function applied to each element in the collection. */ -public inline fun Iterable.sumByDouble(transform: (T) -> Double): Double { +public inline fun Iterable.sumByDouble(selector: (T) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } @@ -1631,20 +1632,20 @@ public operator fun Iterable.plus(sequence: Sequence): List { /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun Iterable.zip(array: Array): List> { - return zip(array) { t1, t2 -> t1 to t2 } +public infix fun Iterable.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun Iterable.zip(array: Array, transform: (T, R) -> V): List { - val arraySize = array.size +public inline fun Iterable.zip(other: Array, transform: (T, R) -> V): List { + val arraySize = other.size val list = ArrayList(Math.min(collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in this) { if (i >= arraySize) break - list.add(transform(element, array[i++])) + list.add(transform(element, other[i++])) } return list } diff --git a/libraries/stdlib/src/generated/_Maps.kt b/libraries/stdlib/src/generated/_Maps.kt index 38596846b8e..5ccbf6f8d45 100644 --- a/libraries/stdlib/src/generated/_Maps.kt +++ b/libraries/stdlib/src/generated/_Maps.kt @@ -128,23 +128,23 @@ public inline fun Map.count(predicate: (Map.Entry) -> Boolean } /** - * Performs the given [operation] on each entry. + * Performs the given [action] on each entry. */ -public inline fun Map.forEach(operation: (Map.Entry) -> Unit): Unit { - for (element in this) operation(element) +public inline fun Map.forEach(action: (Map.Entry) -> Unit): Unit { + for (element in this) action(element) } /** * Returns the first map entry yielding the largest value of the given function or `null` if there are no entries. */ -public inline fun > Map.maxBy(f: (Map.Entry) -> R): Map.Entry? { +public inline fun > Map.maxBy(selector: (Map.Entry) -> R): Map.Entry? { val iterator = iterator() if (!iterator.hasNext()) return null var maxElem = iterator.next() - var maxValue = f(maxElem) + var maxValue = selector(maxElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -156,14 +156,14 @@ public inline fun > Map.maxBy(f: (Map.Entry) /** * Returns the first map entry yielding the smallest value of the given function or `null` if there are no entries. */ -public inline fun > Map.minBy(f: (Map.Entry) -> R): Map.Entry? { +public inline fun > Map.minBy(selector: (Map.Entry) -> R): Map.Entry? { val iterator = iterator() if (!iterator.hasNext()) return null var minElem = iterator.next() - var minValue = f(minElem) + var minValue = selector(minElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 0e1b8530d21..fe6fb4ca544 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -488,13 +488,13 @@ public fun Sequence.toArrayList(): ArrayList { } /** - * Appends all elements to the given [collection]. + * Appends all elements to the given [destination] collection. */ -public fun > Sequence.toCollection(collection: C): C { +public fun > Sequence.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** @@ -582,18 +582,18 @@ public inline fun > Sequence.flatMapTo(dest } /** - * Returns a map of the elements in original sequence grouped by the result of given [toKey] function. + * Returns a map of the elements in original sequence grouped by the key returned by the given [selector] function. */ -public inline fun Sequence.groupBy(toKey: (T) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun Sequence.groupBy(selector: (T) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Appends elements from original sequence grouped by the result of given [toKey] function to the given [map]. + * Appends elements from original sequence grouped by the key returned by the given [selector] function to the given [map]. */ -public inline fun Sequence.groupByTo(map: MutableMap>, toKey: (T) -> K): Map> { +public inline fun Sequence.groupByTo(map: MutableMap>, selector: (T) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -687,11 +687,12 @@ public fun Sequence.distinct(): Sequence { } /** - * Returns a sequence containing only distinct elements from the given sequence according to the [keySelector]. + * Returns a sequence containing only elements from the given sequence + * having distinct keys returned by the given [selector] function. * The elements in the resulting sequence are in the same order as they were in the source sequence. */ -public fun Sequence.distinctBy(keySelector: (T) -> K): Sequence { - return DistinctSequence(this, keySelector) +public fun Sequence.distinctBy(selector: (T) -> K): Sequence { + return DistinctSequence(this, selector) } /** @@ -755,18 +756,18 @@ public inline fun Sequence.fold(initial: R, operation: (R, T) -> R): R } /** - * Performs the given [operation] on each element. + * Performs the given [action] on each element. */ -public inline fun Sequence.forEach(operation: (T) -> Unit): Unit { - for (element in this) operation(element) +public inline fun Sequence.forEach(action: (T) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each element, providing sequential index with the element. + * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun Sequence.forEachIndexed(operation: (Int, T) -> Unit): Unit { +public inline fun Sequence.forEachIndexed(action: (Int, T) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** @@ -786,14 +787,14 @@ public fun > Sequence.max(): T? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Sequence.maxBy(f: (T) -> R): T? { +public inline fun , T : Any> Sequence.maxBy(selector: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null var maxElem = iterator.next() - var maxValue = f(maxElem) + var maxValue = selector(maxElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -819,14 +820,14 @@ public fun > Sequence.min(): T? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Sequence.minBy(f: (T) -> R): T? { +public inline fun , T : Any> Sequence.minBy(selector: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null var minElem = iterator.next() - var minValue = f(minElem) + var minValue = selector(minElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -865,23 +866,23 @@ public inline fun Sequence.reduce(operation: (S, T) -> S): S { } /** - * Returns the sum of all values produced by [transform] function applied to each element in the sequence. + * Returns the sum of all values produced by [selector] function applied to each element in the sequence. */ -public inline fun Sequence.sumBy(transform: (T) -> Int): Int { +public inline fun Sequence.sumBy(selector: (T) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each element in the sequence. + * Returns the sum of all values produced by [selector] function applied to each element in the sequence. */ -public inline fun Sequence.sumByDouble(transform: (T) -> Double): Double { +public inline fun Sequence.sumByDouble(selector: (T) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } @@ -1007,18 +1008,18 @@ public operator fun Sequence.plus(sequence: Sequence): Sequence { } /** - * Returns a sequence of pairs built from elements of both collections with same indexes. + * Returns a sequence of pairs built from elements of both sequences with same indexes. * Resulting sequence has length of shortest input sequence. */ -public infix fun Sequence.zip(sequence: Sequence): Sequence> { - return MergingSequence(this, sequence) { t1, t2 -> t1 to t2 } +public infix fun Sequence.zip(other: Sequence): Sequence> { + return MergingSequence(this, other) { t1, t2 -> t1 to t2 } } /** * Returns a sequence of values built from elements of both collections with same indexes using provided [transform]. Resulting sequence has length of shortest input sequences. */ -public fun Sequence.zip(sequence: Sequence, transform: (T, R) -> V): Sequence { - return MergingSequence(this, sequence, transform) +public fun Sequence.zip(other: Sequence, transform: (T, R) -> V): Sequence { + return MergingSequence(this, other, transform) } /** diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index 46a6b395e0c..f1fdeb80ceb 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -747,24 +747,24 @@ public fun String.toArrayList(): ArrayList { } /** - * Appends all characters to the given [collection]. + * Appends all characters to the given [destination] collection. */ -public fun > CharSequence.toCollection(collection: C): C { +public fun > CharSequence.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** - * Appends all characters to the given [collection]. + * Appends all characters to the given [destination] collection. */ @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun > String.toCollection(collection: C): C { +public fun > String.toCollection(destination: C): C { for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination } /** @@ -940,26 +940,26 @@ public inline fun > String.flatMapTo(destination: } /** - * Returns a map of the characters in original char sequence grouped by the result of given [toKey] function. + * Returns a map of the characters in original char sequence grouped by the key returned by the given [selector] function. */ -public inline fun CharSequence.groupBy(toKey: (Char) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun CharSequence.groupBy(selector: (Char) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Returns a map of the characters in original string grouped by the result of given [toKey] function. + * Returns a map of the characters in original string grouped by the key returned by the given [selector] function. */ @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.groupBy(toKey: (Char) -> K): Map> { - return groupByTo(LinkedHashMap>(), toKey) +public inline fun String.groupBy(selector: (Char) -> K): Map> { + return groupByTo(LinkedHashMap>(), selector) } /** - * Appends characters from original char sequence grouped by the result of given [toKey] function to the given [map]. + * Appends characters from original char sequence grouped by the key returned by the given [selector] function to the given [map]. */ -public inline fun CharSequence.groupByTo(map: MutableMap>, toKey: (Char) -> K): Map> { +public inline fun CharSequence.groupByTo(map: MutableMap>, selector: (Char) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -967,12 +967,12 @@ public inline fun CharSequence.groupByTo(map: MutableMap String.groupByTo(map: MutableMap>, toKey: (Char) -> K): Map> { +public inline fun String.groupByTo(map: MutableMap>, selector: (Char) -> K): Map> { for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } @@ -1236,35 +1236,35 @@ public inline fun String.foldRight(initial: R, operation: (Char, R) -> R): R } /** - * Performs the given [operation] on each character. + * Performs the given [action] on each character. */ -public inline fun CharSequence.forEach(operation: (Char) -> Unit): Unit { - for (element in this) operation(element) +public inline fun CharSequence.forEach(action: (Char) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each character. + * Performs the given [action] on each character. */ @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.forEach(operation: (Char) -> Unit): Unit { - for (element in this) operation(element) +public inline fun String.forEach(action: (Char) -> Unit): Unit { + for (element in this) action(element) } /** - * Performs the given [operation] on each character, providing sequential index with the character. + * Performs the given [action] on each character, providing sequential index with the character. */ -public inline fun CharSequence.forEachIndexed(operation: (Int, Char) -> Unit): Unit { +public inline fun CharSequence.forEachIndexed(action: (Int, Char) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** - * Performs the given [operation] on each character, providing sequential index with the character. + * Performs the given [action] on each character, providing sequential index with the character. */ @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.forEachIndexed(operation: (Int, Char) -> Unit): Unit { +public inline fun String.forEachIndexed(action: (Int, Char) -> Unit): Unit { var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) } /** @@ -1297,13 +1297,13 @@ public fun String.max(): Char? { /** * Returns the first character yielding the largest value of the given function or `null` if there are no characters. */ -public inline fun > CharSequence.maxBy(f: (Char) -> R): Char? { +public inline fun > CharSequence.maxBy(selector: (Char) -> R): Char? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -1316,13 +1316,13 @@ public inline fun > CharSequence.maxBy(f: (Char) -> R): Char? * Returns the first character yielding the largest value of the given function or `null` if there are no characters. */ @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun > String.maxBy(f: (Char) -> R): Char? { +public inline fun > String.maxBy(selector: (Char) -> R): Char? { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -1361,13 +1361,13 @@ public fun String.min(): Char? { /** * Returns the first character yielding the smallest value of the given function or `null` if there are no characters. */ -public inline fun > CharSequence.minBy(f: (Char) -> R): Char? { +public inline fun > CharSequence.minBy(selector: (Char) -> R): Char? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -1380,13 +1380,13 @@ public inline fun > CharSequence.minBy(f: (Char) -> R): Char? * Returns the first character yielding the smallest value of the given function or `null` if there are no characters. */ @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun > String.minBy(f: (Char) -> R): Char? { +public inline fun > String.minBy(selector: (Char) -> R): Char? { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -1484,47 +1484,47 @@ public inline fun String.reduceRight(operation: (Char, Char) -> Char): Char { } /** - * Returns the sum of all values produced by [transform] function applied to each character in the char sequence. + * Returns the sum of all values produced by [selector] function applied to each character in the char sequence. */ -public inline fun CharSequence.sumBy(transform: (Char) -> Int): Int { +public inline fun CharSequence.sumBy(selector: (Char) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each character in the string. + * Returns the sum of all values produced by [selector] function applied to each character in the string. */ @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.sumBy(transform: (Char) -> Int): Int { +public inline fun String.sumBy(selector: (Char) -> Int): Int { var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each character in the char sequence. + * Returns the sum of all values produced by [selector] function applied to each character in the char sequence. */ -public inline fun CharSequence.sumByDouble(transform: (Char) -> Double): Double { +public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } /** - * Returns the sum of all values produced by [transform] function applied to each character in the string. + * Returns the sum of all values produced by [selector] function applied to each character in the string. */ @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.sumByDouble(transform: (Char) -> Double): Double { +public inline fun String.sumByDouble(selector: (Char) -> Double): Double { var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum } diff --git a/libraries/stdlib/src/kotlin/io/Constants.kt b/libraries/stdlib/src/kotlin/io/Constants.kt index 7905f8f3df8..9838589ef1b 100644 --- a/libraries/stdlib/src/kotlin/io/Constants.kt +++ b/libraries/stdlib/src/kotlin/io/Constants.kt @@ -5,7 +5,7 @@ package kotlin.io /** * Returns the default buffer size when working with buffered streams. - */ +*/ public val defaultBufferSize: Int = 64 * 1024 /** * Returns the default block size for forEachBlock(). diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt index cbd3ad494d3..195d84a5250 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt @@ -111,34 +111,34 @@ fun aggregates(): List { } } - templates add f("sumBy(transform: (T) -> Int)") { + templates add f("sumBy(selector: (T) -> Int)") { inline(true) include(CharSequences, Strings) deprecate(Strings) { forBinaryCompatibility } - doc { f -> "Returns the sum of all values produced by [transform] function applied to each ${f.element} in the ${f.collection}." } + doc { f -> "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." } returns("Int") body { """ var sum: Int = 0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum """ } } - templates add f("sumByDouble(transform: (T) -> Double)") { + templates add f("sumByDouble(selector: (T) -> Double)") { inline(true) include(CharSequences, Strings) deprecate(Strings) { forBinaryCompatibility } - doc { f -> "Returns the sum of all values produced by [transform] function applied to each ${f.element} in the ${f.collection}." } + doc { f -> "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." } returns("Double") body { """ var sum: Double = 0.0 for (element in this) { - sum += transform(element) + sum += selector(element) } return sum """ @@ -177,7 +177,7 @@ fun aggregates(): List { } } - templates add f("minBy(f: (T) -> R)") { + templates add f("minBy(selector: (T) -> R)") { inline(true) doc { f -> "Returns the first ${f.element} yielding the smallest value of the given function or `null` if there are no ${f.element}s." } @@ -190,10 +190,10 @@ fun aggregates(): List { if (!iterator.hasNext()) return null var minElem = iterator.next() - var minValue = f(minElem) + var minValue = selector(minElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -208,10 +208,10 @@ fun aggregates(): List { if (isEmpty()) return null var minElem = this[0] - var minValue = f(minElem) + var minValue = selector(minElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -222,7 +222,7 @@ fun aggregates(): List { } } - templates add f("minBy(f: (T) -> R)") { + templates add f("minBy(selector: (T) -> R)") { inline(true) only(Maps) @@ -235,10 +235,10 @@ fun aggregates(): List { if (!iterator.hasNext()) return null var minElem = iterator.next() - var minValue = f(minElem) + var minValue = selector(minElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (minValue > v) { minElem = e minValue = v @@ -283,7 +283,7 @@ fun aggregates(): List { } } - templates add f("maxBy(f: (T) -> R)") { + templates add f("maxBy(selector: (T) -> R)") { inline(true) doc { f -> "Returns the first ${f.element} yielding the largest value of the given function or `null` if there are no ${f.element}s." } @@ -296,10 +296,10 @@ fun aggregates(): List { if (!iterator.hasNext()) return null var maxElem = iterator.next() - var maxValue = f(maxElem) + var maxValue = selector(maxElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -314,10 +314,10 @@ fun aggregates(): List { if (isEmpty()) return null var maxElem = this[0] - var maxValue = f(maxElem) + var maxValue = selector(maxElem) for (i in 1..lastIndex) { val e = this[i] - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -328,7 +328,7 @@ fun aggregates(): List { } } - templates add f("maxBy(f: (T) -> R)") { + templates add f("maxBy(selector: (T) -> R)") { inline(true) only(Maps) @@ -341,10 +341,10 @@ fun aggregates(): List { if (!iterator.hasNext()) return null var maxElem = iterator.next() - var maxValue = f(maxElem) + var maxValue = selector(maxElem) while (iterator.hasNext()) { val e = iterator.next() - val v = f(e) + val v = selector(e) if (maxValue < v) { maxElem = e maxValue = v @@ -482,30 +482,30 @@ fun aggregates(): List { } } - templates add f("forEach(operation: (T) -> Unit)") { + templates add f("forEach(action: (T) -> Unit)") { inline(true) - doc { f -> "Performs the given [operation] on each ${f.element}." } + doc { f -> "Performs the given [action] on each ${f.element}." } returns("Unit") body { """ - for (element in this) operation(element) + for (element in this) action(element) """ } deprecate(Strings) { forBinaryCompatibility } include(Maps, CharSequences, Strings) } - templates add f("forEachIndexed(operation: (Int, T) -> Unit)") { + templates add f("forEachIndexed(action: (Int, T) -> Unit)") { inline(true) deprecate(Strings) { forBinaryCompatibility } include(CharSequences, Strings) - doc { f -> "Performs the given [operation] on each ${f.element}, providing sequential index with the ${f.element}." } + doc { f -> "Performs the given [action] on each ${f.element}, providing sequential index with the ${f.element}." } returns("Unit") body { """ var index = 0 - for (item in this) operation(index++, item) + for (item in this) action(index++, item) """ } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index f8a14af3ae1..84d202c211a 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -480,7 +480,7 @@ fun generators(): List { } } - templates add f("zip(array: Array, transform: (T, R) -> V)") { + templates add f("zip(other: Array, transform: (T, R) -> V)") { exclude(Sequences) doc { """ @@ -493,22 +493,22 @@ fun generators(): List { inline(true) body { """ - val arraySize = array.size + val arraySize = other.size val list = ArrayList(Math.min(collectionSizeOrDefault(10), arraySize)) var i = 0 for (element in this) { if (i >= arraySize) break - list.add(transform(element, array[i++])) + list.add(transform(element, other[i++])) } return list """ } body(ArraysOfObjects, ArraysOfPrimitives) { """ - val size = Math.min(size, array.size) + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list """ @@ -516,7 +516,7 @@ fun generators(): List { } - templates add f("zip(array: SELF, transform: (T, T) -> V)") { + templates add f("zip(other: SELF, transform: (T, T) -> V)") { only(ArraysOfPrimitives) doc { """ @@ -528,17 +528,17 @@ fun generators(): List { inline(true) body() { """ - val size = Math.min(size, array.size) + val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { - list.add(transform(this[i], array[i])) + list.add(transform(this[i], other[i])) } return list """ } } - templates add f("zip(sequence: Sequence, transform: (T, R) -> V)") { + templates add f("zip(other: Sequence, transform: (T, R) -> V)") { only(Sequences) doc { """ @@ -550,7 +550,7 @@ fun generators(): List { returns("Sequence") body { """ - return MergingSequence(this, sequence, transform) + return MergingSequence(this, other, transform) """ } } @@ -614,7 +614,7 @@ fun generators(): List { } } - templates add f("zip(array: Array)") { + templates add f("zip(other: Array)") { infix(true) exclude(Sequences) doc { @@ -626,12 +626,12 @@ fun generators(): List { returns("List>") body { """ - return zip(array) { t1, t2 -> t1 to t2 } + return zip(other) { t1, t2 -> t1 to t2 } """ } } - templates add f("zip(array: SELF)") { + templates add f("zip(other: SELF)") { infix(true) only(ArraysOfPrimitives) doc { @@ -642,17 +642,17 @@ fun generators(): List { returns("List>") body { """ - return zip(array) { t1, t2 -> t1 to t2 } + return zip(other) { t1, t2 -> t1 to t2 } """ } } - templates add f("zip(sequence: Sequence)") { + templates add f("zip(other: Sequence)") { infix(true) only(Sequences) doc { """ - Returns a sequence of pairs built from elements of both collections with same indexes. + Returns a sequence of pairs built from elements of both sequences with same indexes. Resulting sequence has length of shortest input sequence. """ } @@ -660,7 +660,7 @@ fun generators(): List { returns("Sequence>") body { """ - return MergingSequence(this, sequence) { t1, t2 -> t1 to t2 } + return MergingSequence(this, other) { t1, t2 -> t1 to t2 } """ } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt index f4e0c18ffcd..41d05eea1d4 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt @@ -284,29 +284,29 @@ fun mapping(): List { } } - templates add f("groupBy(toKey: (T) -> K)") { + templates add f("groupBy(selector: (T) -> K)") { inline(true) deprecate(Strings) { forBinaryCompatibility } include(CharSequences, Strings) - doc { f -> "Returns a map of the ${f.element}s in original ${f.collection} grouped by the result of given [toKey] function." } + doc { f -> "Returns a map of the ${f.element}s in original ${f.collection} grouped by the key returned by the given [selector] function." } typeParam("K") returns("Map>") - body { "return groupByTo(LinkedHashMap>(), toKey)" } + body { "return groupByTo(LinkedHashMap>(), selector)" } } - templates add f("groupByTo(map: MutableMap>, toKey: (T) -> K)") { + templates add f("groupByTo(map: MutableMap>, selector: (T) -> K)") { inline(true) deprecate(Strings) { forBinaryCompatibility } include(CharSequences, Strings) typeParam("K") - doc { f -> "Appends ${f.element}s from original ${f.collection} grouped by the result of given [toKey] function to the given [map]." } + doc { f -> "Appends ${f.element}s from original ${f.collection} grouped by the key returned by the given [selector] function to the given [map]." } returns("Map>") body { """ for (element in this) { - val key = toKey(element) + val key = selector(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Sets.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Sets.kt index 3cd28b5c29d..e06f951e82a 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Sets.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Sets.kt @@ -50,11 +50,12 @@ fun sets(): List { body(Sequences) { "return this.distinctBy { it }" } } - templates add f("distinctBy(keySelector: (T) -> K)") { + templates add f("distinctBy(selector: (T) -> K)") { exclude(Strings) doc { f -> """ - Returns a ${f.mapResult} containing only distinct ${f.element}s from the given ${f.collection} according to the [keySelector]. + Returns a ${f.mapResult} containing only ${f.element}s from the given ${f.collection} + having distinct keys returned by the given [selector] function. The ${f.element}s in the resulting ${f.mapResult} are in the same order as they were in the source ${f.collection}. """ @@ -68,7 +69,7 @@ fun sets(): List { val set = HashSet() val list = ArrayList() for (e in this) { - val key = keySelector(e) + val key = selector(e) if (set.add(key)) list.add(e) } @@ -80,7 +81,7 @@ fun sets(): List { returns(Sequences) { "Sequence" } body(Sequences) { """ - return DistinctSequence(this, keySelector) + return DistinctSequence(this, selector) """ } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt index d5ea9fbe3e9..a63e6a833a1 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt @@ -5,18 +5,18 @@ import templates.Family.* fun snapshots(): List { val templates = arrayListOf() - templates add f("toCollection(collection: C)") { + templates add f("toCollection(destination: C)") { deprecate(Strings) { forBinaryCompatibility } include(CharSequences, Strings) - doc { f -> "Appends all ${f.element}s to the given [collection]." } + doc { f -> "Appends all ${f.element}s to the given [destination] collection." } returns("C") typeParam("C : MutableCollection") body { """ for (item in this) { - collection.add(item) + destination.add(item) } - return collection + return destination """ } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index b0ed8b40b35..8f601ee90c3 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -244,15 +244,16 @@ fun specialJVM(): List { """ } + // TODO: Use own readonly kotlin.AbstractList body(ArraysOfPrimitives) { """ return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(o: T): Boolean = this@asList.contains(o) + override fun contains(element: T): Boolean = this@asList.contains(element) override fun get(index: Int): T = this@asList[index] - override fun indexOf(o: T): Int = this@asList.indexOf(o) - override fun lastIndexOf(o: T): Int = this@asList.lastIndexOf(o) + override fun indexOf(element: T): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: T): Int = this@asList.lastIndexOf(element) } """ }