StdLib: Rename method parameters (generated code)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -992,13 +992,13 @@ public fun <T> Iterable<T>.toArrayList(): ArrayList<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given [collection].
|
||||
* Appends all elements to the given [destination] collection.
|
||||
*/
|
||||
public fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(collection: C): C {
|
||||
public fun <T, C : MutableCollection<in T>> Iterable<T>.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 <T, R, C : MutableCollection<in R>> Iterable<T>.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 <T, K> Iterable<T>.groupBy(toKey: (T) -> K): Map<K, List<T>> {
|
||||
return groupByTo(LinkedHashMap<K, MutableList<T>>(), toKey)
|
||||
public inline fun <T, K> Iterable<T>.groupBy(selector: (T) -> K): Map<K, List<T>> {
|
||||
return groupByTo(LinkedHashMap<K, MutableList<T>>(), 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 <T, K> Iterable<T>.groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K): Map<K, MutableList<T>> {
|
||||
public inline fun <T, K> Iterable<T>.groupByTo(map: MutableMap<K, MutableList<T>>, selector: (T) -> K): Map<K, MutableList<T>> {
|
||||
for (element in this) {
|
||||
val key = toKey(element)
|
||||
val key = selector(element)
|
||||
val list = map.getOrPut(key) { ArrayList<T>() }
|
||||
list.add(element)
|
||||
}
|
||||
@@ -1193,14 +1193,15 @@ public fun <T> Iterable<T>.distinct(): List<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 <T, K> Iterable<T>.distinctBy(keySelector: (T) -> K): List<T> {
|
||||
public inline fun <T, K> Iterable<T>.distinctBy(selector: (T) -> K): List<T> {
|
||||
val set = HashSet<K>()
|
||||
val list = ArrayList<T>()
|
||||
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 <T, R> List<T>.foldRight(initial: R, operation: (T, R) -> R):
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the given [operation] on each element.
|
||||
* Performs the given [action] on each element.
|
||||
*/
|
||||
public inline fun <T> Iterable<T>.forEach(operation: (T) -> Unit): Unit {
|
||||
for (element in this) operation(element)
|
||||
public inline fun <T> Iterable<T>.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 <T> Iterable<T>.forEachIndexed(operation: (Int, T) -> Unit): Unit {
|
||||
public inline fun <T> Iterable<T>.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 <T : Comparable<T>> Iterable<T>.max(): T? {
|
||||
/**
|
||||
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
|
||||
*/
|
||||
public inline fun <R : Comparable<R>, T : Any> Iterable<T>.maxBy(f: (T) -> R): T? {
|
||||
public inline fun <R : Comparable<R>, T : Any> Iterable<T>.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 <T : Comparable<T>> Iterable<T>.min(): T? {
|
||||
/**
|
||||
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
|
||||
*/
|
||||
public inline fun <R : Comparable<R>, T : Any> Iterable<T>.minBy(f: (T) -> R): T? {
|
||||
public inline fun <R : Comparable<R>, T : Any> Iterable<T>.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 <S, T: S> List<T>.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 <T> Iterable<T>.sumBy(transform: (T) -> Int): Int {
|
||||
public inline fun <T> Iterable<T>.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 <T> Iterable<T>.sumByDouble(transform: (T) -> Double): Double {
|
||||
public inline fun <T> Iterable<T>.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 <T> Iterable<T>.plus(sequence: Sequence<T>): List<T> {
|
||||
/**
|
||||
* Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection.
|
||||
*/
|
||||
public infix fun <T, R> Iterable<T>.zip(array: Array<out R>): List<Pair<T, R>> {
|
||||
return zip(array) { t1, t2 -> t1 to t2 }
|
||||
public infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>> {
|
||||
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 <T, R, V> Iterable<T>.zip(array: Array<out R>, transform: (T, R) -> V): List<V> {
|
||||
val arraySize = array.size
|
||||
public inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (T, R) -> V): List<V> {
|
||||
val arraySize = other.size
|
||||
val list = ArrayList<V>(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
|
||||
}
|
||||
|
||||
@@ -128,23 +128,23 @@ public inline fun <K, V> Map<K, V>.count(predicate: (Map.Entry<K, V>) -> Boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the given [operation] on each entry.
|
||||
* Performs the given [action] on each entry.
|
||||
*/
|
||||
public inline fun <K, V> Map<K, V>.forEach(operation: (Map.Entry<K, V>) -> Unit): Unit {
|
||||
for (element in this) operation(element)
|
||||
public inline fun <K, V> Map<K, V>.forEach(action: (Map.Entry<K, V>) -> 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 <K, V, R : Comparable<R>> Map<K, V>.maxBy(f: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
public inline fun <K, V, R : Comparable<R>> Map<K, V>.maxBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
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 <K, V, R : Comparable<R>> Map<K, V>.maxBy(f: (Map.Entry<K, V>)
|
||||
/**
|
||||
* Returns the first map entry yielding the smallest value of the given function or `null` if there are no entries.
|
||||
*/
|
||||
public inline fun <K, V, R : Comparable<R>> Map<K, V>.minBy(f: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
public inline fun <K, V, R : Comparable<R>> Map<K, V>.minBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
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
|
||||
|
||||
@@ -488,13 +488,13 @@ public fun <T> Sequence<T>.toArrayList(): ArrayList<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements to the given [collection].
|
||||
* Appends all elements to the given [destination] collection.
|
||||
*/
|
||||
public fun <T, C : MutableCollection<in T>> Sequence<T>.toCollection(collection: C): C {
|
||||
public fun <T, C : MutableCollection<in T>> Sequence<T>.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 <T, R, C : MutableCollection<in R>> Sequence<T>.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 <T, K> Sequence<T>.groupBy(toKey: (T) -> K): Map<K, List<T>> {
|
||||
return groupByTo(LinkedHashMap<K, MutableList<T>>(), toKey)
|
||||
public inline fun <T, K> Sequence<T>.groupBy(selector: (T) -> K): Map<K, List<T>> {
|
||||
return groupByTo(LinkedHashMap<K, MutableList<T>>(), 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 <T, K> Sequence<T>.groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K): Map<K, MutableList<T>> {
|
||||
public inline fun <T, K> Sequence<T>.groupByTo(map: MutableMap<K, MutableList<T>>, selector: (T) -> K): Map<K, MutableList<T>> {
|
||||
for (element in this) {
|
||||
val key = toKey(element)
|
||||
val key = selector(element)
|
||||
val list = map.getOrPut(key) { ArrayList<T>() }
|
||||
list.add(element)
|
||||
}
|
||||
@@ -687,11 +687,12 @@ public fun <T> Sequence<T>.distinct(): Sequence<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 <T, K> Sequence<T>.distinctBy(keySelector: (T) -> K): Sequence<T> {
|
||||
return DistinctSequence(this, keySelector)
|
||||
public fun <T, K> Sequence<T>.distinctBy(selector: (T) -> K): Sequence<T> {
|
||||
return DistinctSequence(this, selector)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -755,18 +756,18 @@ public inline fun <T, R> Sequence<T>.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 <T> Sequence<T>.forEach(operation: (T) -> Unit): Unit {
|
||||
for (element in this) operation(element)
|
||||
public inline fun <T> Sequence<T>.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 <T> Sequence<T>.forEachIndexed(operation: (Int, T) -> Unit): Unit {
|
||||
public inline fun <T> Sequence<T>.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 <T : Comparable<T>> Sequence<T>.max(): T? {
|
||||
/**
|
||||
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
|
||||
*/
|
||||
public inline fun <R : Comparable<R>, T : Any> Sequence<T>.maxBy(f: (T) -> R): T? {
|
||||
public inline fun <R : Comparable<R>, T : Any> Sequence<T>.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 <T : Comparable<T>> Sequence<T>.min(): T? {
|
||||
/**
|
||||
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
|
||||
*/
|
||||
public inline fun <R : Comparable<R>, T : Any> Sequence<T>.minBy(f: (T) -> R): T? {
|
||||
public inline fun <R : Comparable<R>, T : Any> Sequence<T>.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 <S, T: S> Sequence<T>.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 <T> Sequence<T>.sumBy(transform: (T) -> Int): Int {
|
||||
public inline fun <T> Sequence<T>.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 <T> Sequence<T>.sumByDouble(transform: (T) -> Double): Double {
|
||||
public inline fun <T> Sequence<T>.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 <T> Sequence<T>.plus(sequence: Sequence<T>): Sequence<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 <T, R> Sequence<T>.zip(sequence: Sequence<R>): Sequence<Pair<T, R>> {
|
||||
return MergingSequence(this, sequence) { t1, t2 -> t1 to t2 }
|
||||
public infix fun <T, R> Sequence<T>.zip(other: Sequence<R>): Sequence<Pair<T, R>> {
|
||||
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 <T, R, V> Sequence<T>.zip(sequence: Sequence<R>, transform: (T, R) -> V): Sequence<V> {
|
||||
return MergingSequence(this, sequence, transform)
|
||||
public fun <T, R, V> Sequence<T>.zip(other: Sequence<R>, transform: (T, R) -> V): Sequence<V> {
|
||||
return MergingSequence(this, other, transform)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -747,24 +747,24 @@ public fun String.toArrayList(): ArrayList<Char> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all characters to the given [collection].
|
||||
* Appends all characters to the given [destination] collection.
|
||||
*/
|
||||
public fun <C : MutableCollection<in Char>> CharSequence.toCollection(collection: C): C {
|
||||
public fun <C : MutableCollection<in Char>> 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 <C : MutableCollection<in Char>> String.toCollection(collection: C): C {
|
||||
public fun <C : MutableCollection<in Char>> 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 <R, C : MutableCollection<in R>> 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 <K> CharSequence.groupBy(toKey: (Char) -> K): Map<K, List<Char>> {
|
||||
return groupByTo(LinkedHashMap<K, MutableList<Char>>(), toKey)
|
||||
public inline fun <K> CharSequence.groupBy(selector: (Char) -> K): Map<K, List<Char>> {
|
||||
return groupByTo(LinkedHashMap<K, MutableList<Char>>(), 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 <K> String.groupBy(toKey: (Char) -> K): Map<K, List<Char>> {
|
||||
return groupByTo(LinkedHashMap<K, MutableList<Char>>(), toKey)
|
||||
public inline fun <K> String.groupBy(selector: (Char) -> K): Map<K, List<Char>> {
|
||||
return groupByTo(LinkedHashMap<K, MutableList<Char>>(), 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 <K> CharSequence.groupByTo(map: MutableMap<K, MutableList<Char>>, toKey: (Char) -> K): Map<K, MutableList<Char>> {
|
||||
public inline fun <K> CharSequence.groupByTo(map: MutableMap<K, MutableList<Char>>, selector: (Char) -> K): Map<K, MutableList<Char>> {
|
||||
for (element in this) {
|
||||
val key = toKey(element)
|
||||
val key = selector(element)
|
||||
val list = map.getOrPut(key) { ArrayList<Char>() }
|
||||
list.add(element)
|
||||
}
|
||||
@@ -967,12 +967,12 @@ public inline fun <K> CharSequence.groupByTo(map: MutableMap<K, MutableList<Char
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends characters from original string grouped by the result of given [toKey] function to the given [map].
|
||||
* Appends characters from original string grouped by the key returned by the given [selector] function to the given [map].
|
||||
*/
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public inline fun <K> String.groupByTo(map: MutableMap<K, MutableList<Char>>, toKey: (Char) -> K): Map<K, MutableList<Char>> {
|
||||
public inline fun <K> String.groupByTo(map: MutableMap<K, MutableList<Char>>, selector: (Char) -> K): Map<K, MutableList<Char>> {
|
||||
for (element in this) {
|
||||
val key = toKey(element)
|
||||
val key = selector(element)
|
||||
val list = map.getOrPut(key) { ArrayList<Char>() }
|
||||
list.add(element)
|
||||
}
|
||||
@@ -1236,35 +1236,35 @@ public inline fun <R> 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 <R : Comparable<R>> CharSequence.maxBy(f: (Char) -> R): Char? {
|
||||
public inline fun <R : Comparable<R>> 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 <R : Comparable<R>> 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 <R : Comparable<R>> String.maxBy(f: (Char) -> R): Char? {
|
||||
public inline fun <R : Comparable<R>> 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 <R : Comparable<R>> CharSequence.minBy(f: (Char) -> R): Char? {
|
||||
public inline fun <R : Comparable<R>> 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 <R : Comparable<R>> 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 <R : Comparable<R>> String.minBy(f: (Char) -> R): Char? {
|
||||
public inline fun <R : Comparable<R>> 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
|
||||
}
|
||||
|
||||
@@ -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().
|
||||
|
||||
Reference in New Issue
Block a user