Specify names for parameters of functional types with two or more parameters to ease lambda completion.

#KT-13826
This commit is contained in:
Ilya Gorbunov
2017-01-18 19:46:50 +03:00
parent 96d0f91afc
commit 661ff81e67
21 changed files with 611 additions and 611 deletions
File diff suppressed because it is too large Load Diff
+17 -17
View File
@@ -617,7 +617,7 @@ public inline fun <T> Iterable<T>.filter(predicate: (T) -> Boolean): List<T> {
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*/
public inline fun <T> Iterable<T>.filterIndexed(predicate: (Int, T) -> Boolean): List<T> {
public inline fun <T> Iterable<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): List<T> {
return filterIndexedTo(ArrayList<T>(), predicate)
}
@@ -626,7 +626,7 @@ public inline fun <T> Iterable<T>.filterIndexed(predicate: (Int, T) -> Boolean):
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*/
public inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(destination: C, predicate: (Int, T) -> Boolean): C {
public inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C {
forEachIndexed { index, element ->
if (predicate(index, element)) destination.add(element)
}
@@ -1218,7 +1218,7 @@ public inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {
* and returns the result of the transform applied to the element.
*/
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
public inline fun <T, R> Iterable<T>.mapIndexed(transform: (Int, T) -> R): List<R> {
public inline fun <T, R> Iterable<T>.mapIndexed(transform: (index: Int, T) -> R): List<R> {
return mapIndexedTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)
}
@@ -1228,7 +1228,7 @@ public inline fun <T, R> Iterable<T>.mapIndexed(transform: (Int, T) -> R): List<
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
public inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(transform: (Int, T) -> R?): List<R> {
public inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): List<R> {
return mapIndexedNotNullTo(ArrayList<R>(), transform)
}
@@ -1238,7 +1238,7 @@ public inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(transform: (Int, T)
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
public inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(destination: C, transform: (Int, T) -> R?): C {
public inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C {
forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } }
return destination
}
@@ -1249,7 +1249,7 @@ public inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndex
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(destination: C, transform: (Int, T) -> R): C {
public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C {
var index = 0
for (item in this)
destination.add(transform(index++, item))
@@ -1416,7 +1416,7 @@ public inline fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int {
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
*/
public inline fun <T, R> Iterable<T>.fold(initial: R, operation: (R, T) -> R): R {
public inline fun <T, R> Iterable<T>.fold(initial: R, operation: (acc: R, T) -> R): R {
var accumulator = initial
for (element in this) accumulator = operation(accumulator, element)
return accumulator
@@ -1428,7 +1428,7 @@ public inline fun <T, R> Iterable<T>.fold(initial: R, operation: (R, T) -> R): R
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
public inline fun <T, R> Iterable<T>.foldIndexed(initial: R, operation: (Int, R, T) -> R): R {
public inline fun <T, R> Iterable<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R {
var index = 0
var accumulator = initial
for (element in this) accumulator = operation(index++, accumulator, element)
@@ -1438,7 +1438,7 @@ public inline fun <T, R> Iterable<T>.foldIndexed(initial: R, operation: (Int, R,
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.
*/
public inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, R) -> R): R {
public inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, acc: R) -> R): R {
var accumulator = initial
if (!isEmpty()) {
val iterator = listIterator(size)
@@ -1455,7 +1455,7 @@ public inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, R) -> R):
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
public inline fun <T, R> List<T>.foldRightIndexed(initial: R, operation: (Int, T, R) -> R): R {
public inline fun <T, R> List<T>.foldRightIndexed(initial: R, operation: (index: Int, T, acc: R) -> R): R {
var accumulator = initial
if (!isEmpty()) {
val iterator = listIterator(size)
@@ -1480,7 +1480,7 @@ public inline fun <T> Iterable<T>.forEach(action: (T) -> Unit): Unit {
* @param [action] function that takes the index of an element and the element itself
* and performs the desired action on the element.
*/
public inline fun <T> Iterable<T>.forEachIndexed(action: (Int, T) -> Unit): Unit {
public inline fun <T> Iterable<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit {
var index = 0
for (item in this) action(index++, item)
}
@@ -1682,7 +1682,7 @@ public inline fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C {
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
*/
public inline fun <S, T: S> Iterable<T>.reduce(operation: (S, T) -> S): S {
public inline fun <S, T: S> Iterable<T>.reduce(operation: (acc: S, T) -> S): S {
val iterator = this.iterator()
if (!iterator.hasNext()) throw UnsupportedOperationException("Empty collection can't be reduced.")
var accumulator: S = iterator.next()
@@ -1698,7 +1698,7 @@ public inline fun <S, T: S> Iterable<T>.reduce(operation: (S, T) -> S): S {
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*/
public inline fun <S, T: S> Iterable<T>.reduceIndexed(operation: (Int, S, T) -> S): S {
public inline fun <S, T: S> Iterable<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S {
val iterator = this.iterator()
if (!iterator.hasNext()) throw UnsupportedOperationException("Empty collection can't be reduced.")
var index = 1
@@ -1712,7 +1712,7 @@ public inline fun <S, T: S> Iterable<T>.reduceIndexed(operation: (Int, S, T) ->
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.
*/
public inline fun <S, T: S> List<T>.reduceRight(operation: (T, S) -> S): S {
public inline fun <S, T: S> List<T>.reduceRight(operation: (T, acc: S) -> S): S {
val iterator = listIterator(size)
if (!iterator.hasPrevious())
throw UnsupportedOperationException("Empty list can't be reduced.")
@@ -1729,7 +1729,7 @@ public inline fun <S, T: S> List<T>.reduceRight(operation: (T, S) -> S): S {
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
public inline fun <S, T: S> List<T>.reduceRightIndexed(operation: (Int, T, S) -> S): S {
public inline fun <S, T: S> List<T>.reduceRightIndexed(operation: (index: Int, T, acc: S) -> S): S {
val iterator = listIterator(size)
if (!iterator.hasPrevious())
throw UnsupportedOperationException("Empty list can't be reduced.")
@@ -1968,7 +1968,7 @@ public infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, 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 <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (T, R) -> V): List<V> {
public inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V> {
val arraySize = other.size
val list = ArrayList<V>(minOf(collectionSizeOrDefault(10), arraySize))
var i = 0
@@ -1989,7 +1989,7 @@ public infix fun <T, R> Iterable<T>.zip(other: Iterable<R>): List<Pair<T, 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 <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (T, R) -> V): List<V> {
public inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V> {
val first = iterator()
val second = other.iterator()
val list = ArrayList<V>(minOf(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10)))
+12 -12
View File
@@ -313,7 +313,7 @@ public fun <T> Sequence<T>.filter(predicate: (T) -> Boolean): Sequence<T> {
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*/
public fun <T> Sequence<T>.filterIndexed(predicate: (Int, T) -> Boolean): Sequence<T> {
public fun <T> Sequence<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): Sequence<T> {
// TODO: Rewrite with generalized MapFilterIndexingSequence
return TransformingSequence(FilteringSequence(IndexingSequence(this), true, { predicate(it.index, it.value) }), { it.value })
}
@@ -323,7 +323,7 @@ public fun <T> Sequence<T>.filterIndexed(predicate: (Int, T) -> Boolean): Sequen
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*/
public inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterIndexedTo(destination: C, predicate: (Int, T) -> Boolean): C {
public inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C {
forEachIndexed { index, element ->
if (predicate(index, element)) destination.add(element)
}
@@ -689,7 +689,7 @@ public fun <T, R> Sequence<T>.map(transform: (T) -> R): Sequence<R> {
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
public fun <T, R> Sequence<T>.mapIndexed(transform: (Int, T) -> R): Sequence<R> {
public fun <T, R> Sequence<T>.mapIndexed(transform: (index: Int, T) -> R): Sequence<R> {
return TransformingIndexedSequence(this, transform)
}
@@ -699,7 +699,7 @@ public fun <T, R> Sequence<T>.mapIndexed(transform: (Int, T) -> R): Sequence<R>
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
public fun <T, R : Any> Sequence<T>.mapIndexedNotNull(transform: (Int, T) -> R?): Sequence<R> {
public fun <T, R : Any> Sequence<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): Sequence<R> {
return TransformingIndexedSequence(this, transform).filterNotNull()
}
@@ -709,7 +709,7 @@ public fun <T, R : Any> Sequence<T>.mapIndexedNotNull(transform: (Int, T) -> R?)
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
public inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndexedNotNullTo(destination: C, transform: (Int, T) -> R?): C {
public inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C {
forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } }
return destination
}
@@ -720,7 +720,7 @@ public inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndex
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(destination: C, transform: (Int, T) -> R): C {
public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C {
var index = 0
for (item in this)
destination.add(transform(index++, item))
@@ -836,7 +836,7 @@ public inline fun <T> Sequence<T>.count(predicate: (T) -> Boolean): Int {
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
*/
public inline fun <T, R> Sequence<T>.fold(initial: R, operation: (R, T) -> R): R {
public inline fun <T, R> Sequence<T>.fold(initial: R, operation: (acc: R, T) -> R): R {
var accumulator = initial
for (element in this) accumulator = operation(accumulator, element)
return accumulator
@@ -848,7 +848,7 @@ public inline fun <T, R> Sequence<T>.fold(initial: R, operation: (R, T) -> R): R
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
public inline fun <T, R> Sequence<T>.foldIndexed(initial: R, operation: (Int, R, T) -> R): R {
public inline fun <T, R> Sequence<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R {
var index = 0
var accumulator = initial
for (element in this) accumulator = operation(index++, accumulator, element)
@@ -867,7 +867,7 @@ public inline fun <T> Sequence<T>.forEach(action: (T) -> Unit): Unit {
* @param [action] function that takes the index of an element and the element itself
* and performs the desired action on the element.
*/
public inline fun <T> Sequence<T>.forEachIndexed(action: (Int, T) -> Unit): Unit {
public inline fun <T> Sequence<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit {
var index = 0
for (item in this) action(index++, item)
}
@@ -1072,7 +1072,7 @@ public fun <T> Sequence<T>.onEach(action: (T) -> Unit): Sequence<T> {
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
*/
public inline fun <S, T: S> Sequence<T>.reduce(operation: (S, T) -> S): S {
public inline fun <S, T: S> Sequence<T>.reduce(operation: (acc: S, T) -> S): S {
val iterator = this.iterator()
if (!iterator.hasNext()) throw UnsupportedOperationException("Empty sequence can't be reduced.")
var accumulator: S = iterator.next()
@@ -1088,7 +1088,7 @@ public inline fun <S, T: S> Sequence<T>.reduce(operation: (S, T) -> S): S {
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*/
public inline fun <S, T: S> Sequence<T>.reduceIndexed(operation: (Int, S, T) -> S): S {
public inline fun <S, T: S> Sequence<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S {
val iterator = this.iterator()
if (!iterator.hasNext()) throw UnsupportedOperationException("Empty sequence can't be reduced.")
var index = 1
@@ -1274,7 +1274,7 @@ public infix fun <T, R> Sequence<T>.zip(other: Sequence<R>): Sequence<Pair<T, R>
/**
* 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(other: Sequence<R>, transform: (T, R) -> V): Sequence<V> {
public fun <T, R, V> Sequence<T>.zip(other: Sequence<R>, transform: (a: T, b: R) -> V): Sequence<V> {
return MergingSequence(this, other, transform)
}
+17 -17
View File
@@ -307,7 +307,7 @@ public inline fun String.filter(predicate: (Char) -> Boolean): String {
* @param [predicate] function that takes the index of a character and the character itself
* and returns the result of predicate evaluation on the character.
*/
public inline fun CharSequence.filterIndexed(predicate: (Int, Char) -> Boolean): CharSequence {
public inline fun CharSequence.filterIndexed(predicate: (index: Int, Char) -> Boolean): CharSequence {
return filterIndexedTo(StringBuilder(), predicate)
}
@@ -316,7 +316,7 @@ public inline fun CharSequence.filterIndexed(predicate: (Int, Char) -> Boolean):
* @param [predicate] function that takes the index of a character and the character itself
* and returns the result of predicate evaluation on the character.
*/
public inline fun String.filterIndexed(predicate: (Int, Char) -> Boolean): String {
public inline fun String.filterIndexed(predicate: (index: Int, Char) -> Boolean): String {
return filterIndexedTo(StringBuilder(), predicate).toString()
}
@@ -325,7 +325,7 @@ public inline fun String.filterIndexed(predicate: (Int, Char) -> Boolean): Strin
* @param [predicate] function that takes the index of a character and the character itself
* and returns the result of predicate evaluation on the character.
*/
public inline fun <C : Appendable> CharSequence.filterIndexedTo(destination: C, predicate: (Int, Char) -> Boolean): C {
public inline fun <C : Appendable> CharSequence.filterIndexedTo(destination: C, predicate: (index: Int, Char) -> Boolean): C {
forEachIndexed { index, element ->
if (predicate(index, element)) destination.append(element)
}
@@ -736,7 +736,7 @@ public inline fun <R> CharSequence.map(transform: (Char) -> R): List<R> {
* @param [transform] function that takes the index of a character and the character itself
* and returns the result of the transform applied to the character.
*/
public inline fun <R> CharSequence.mapIndexed(transform: (Int, Char) -> R): List<R> {
public inline fun <R> CharSequence.mapIndexed(transform: (index: Int, Char) -> R): List<R> {
return mapIndexedTo(ArrayList<R>(length), transform)
}
@@ -746,7 +746,7 @@ public inline fun <R> CharSequence.mapIndexed(transform: (Int, Char) -> R): List
* @param [transform] function that takes the index of a character and the character itself
* and returns the result of the transform applied to the character.
*/
public inline fun <R : Any> CharSequence.mapIndexedNotNull(transform: (Int, Char) -> R?): List<R> {
public inline fun <R : Any> CharSequence.mapIndexedNotNull(transform: (index: Int, Char) -> R?): List<R> {
return mapIndexedNotNullTo(ArrayList<R>(), transform)
}
@@ -756,7 +756,7 @@ public inline fun <R : Any> CharSequence.mapIndexedNotNull(transform: (Int, Char
* @param [transform] function that takes the index of a character and the character itself
* and returns the result of the transform applied to the character.
*/
public inline fun <R : Any, C : MutableCollection<in R>> CharSequence.mapIndexedNotNullTo(destination: C, transform: (Int, Char) -> R?): C {
public inline fun <R : Any, C : MutableCollection<in R>> CharSequence.mapIndexedNotNullTo(destination: C, transform: (index: Int, Char) -> R?): C {
forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } }
return destination
}
@@ -767,7 +767,7 @@ public inline fun <R : Any, C : MutableCollection<in R>> CharSequence.mapIndexed
* @param [transform] function that takes the index of a character and the character itself
* and returns the result of the transform applied to the character.
*/
public inline fun <R, C : MutableCollection<in R>> CharSequence.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C {
public inline fun <R, C : MutableCollection<in R>> CharSequence.mapIndexedTo(destination: C, transform: (index: Int, Char) -> R): C {
var index = 0
for (item in this)
destination.add(transform(index++, item))
@@ -852,7 +852,7 @@ public inline fun CharSequence.count(predicate: (Char) -> Boolean): Int {
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each character.
*/
public inline fun <R> CharSequence.fold(initial: R, operation: (R, Char) -> R): R {
public inline fun <R> CharSequence.fold(initial: R, operation: (acc: R, Char) -> R): R {
var accumulator = initial
for (element in this) accumulator = operation(accumulator, element)
return accumulator
@@ -864,7 +864,7 @@ public inline fun <R> CharSequence.fold(initial: R, operation: (R, Char) -> R):
* @param [operation] function that takes the index of a character, current accumulator value
* and the character itself, and calculates the next accumulator value.
*/
public inline fun <R> CharSequence.foldIndexed(initial: R, operation: (Int, R, Char) -> R): R {
public inline fun <R> CharSequence.foldIndexed(initial: R, operation: (index: Int, acc: R, Char) -> R): R {
var index = 0
var accumulator = initial
for (element in this) accumulator = operation(index++, accumulator, element)
@@ -874,7 +874,7 @@ public inline fun <R> CharSequence.foldIndexed(initial: R, operation: (Int, R, C
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each character and current accumulator value.
*/
public inline fun <R> CharSequence.foldRight(initial: R, operation: (Char, R) -> R): R {
public inline fun <R> CharSequence.foldRight(initial: R, operation: (Char, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
@@ -889,7 +889,7 @@ public inline fun <R> CharSequence.foldRight(initial: R, operation: (Char, R) ->
* @param [operation] function that takes the index of a character, the character itself
* and current accumulator value, and calculates the next accumulator value.
*/
public inline fun <R> CharSequence.foldRightIndexed(initial: R, operation: (Int, Char, R) -> R): R {
public inline fun <R> CharSequence.foldRightIndexed(initial: R, operation: (index: Int, Char, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
@@ -911,7 +911,7 @@ public inline fun CharSequence.forEach(action: (Char) -> Unit): Unit {
* @param [action] function that takes the index of a character and the character itself
* and performs the desired action on the character.
*/
public inline fun CharSequence.forEachIndexed(action: (Int, Char) -> Unit): Unit {
public inline fun CharSequence.forEachIndexed(action: (index: Int, Char) -> Unit): Unit {
var index = 0
for (item in this) action(index++, item)
}
@@ -1031,7 +1031,7 @@ public inline fun <S : CharSequence> S.onEach(action: (Char) -> Unit): S {
/**
* Accumulates value starting with the first character and applying [operation] from left to right to current accumulator value and each character.
*/
public inline fun CharSequence.reduce(operation: (Char, Char) -> Char): Char {
public inline fun CharSequence.reduce(operation: (acc: Char, Char) -> Char): Char {
if (isEmpty())
throw UnsupportedOperationException("Empty char sequence can't be reduced.")
var accumulator = this[0]
@@ -1047,7 +1047,7 @@ public inline fun CharSequence.reduce(operation: (Char, Char) -> Char): Char {
* @param [operation] function that takes the index of a character, current accumulator value
* and the character itself and calculates the next accumulator value.
*/
public inline fun CharSequence.reduceIndexed(operation: (Int, Char, Char) -> Char): Char {
public inline fun CharSequence.reduceIndexed(operation: (index: Int, acc: Char, Char) -> Char): Char {
if (isEmpty())
throw UnsupportedOperationException("Empty char sequence can't be reduced.")
var accumulator = this[0]
@@ -1060,7 +1060,7 @@ public inline fun CharSequence.reduceIndexed(operation: (Int, Char, Char) -> Cha
/**
* Accumulates value starting with last character and applying [operation] from right to left to each character and current accumulator value.
*/
public inline fun CharSequence.reduceRight(operation: (Char, Char) -> Char): Char {
public inline fun CharSequence.reduceRight(operation: (Char, acc: Char) -> Char): Char {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty char sequence can't be reduced.")
var accumulator = get(index--)
@@ -1076,7 +1076,7 @@ public inline fun CharSequence.reduceRight(operation: (Char, Char) -> Char): Cha
* @param [operation] function that takes the index of a character, the character itself
* and current accumulator value, and calculates the next accumulator value.
*/
public inline fun CharSequence.reduceRightIndexed(operation: (Int, Char, Char) -> Char): Char {
public inline fun CharSequence.reduceRightIndexed(operation: (index: Int, Char, acc: Char) -> Char): Char {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty char sequence can't be reduced.")
var accumulator = get(index--)
@@ -1155,7 +1155,7 @@ public infix fun CharSequence.zip(other: CharSequence): List<Pair<Char, Char>> {
/**
* Returns a list of values built from characters of both char sequences with same indexes using provided [transform]. List has length of shortest char sequence.
*/
public inline fun <V> CharSequence.zip(other: CharSequence, transform: (Char, Char) -> V): List<V> {
public inline fun <V> CharSequence.zip(other: CharSequence, transform: (a: Char, b: Char) -> V): List<V> {
val length = minOf(this.length, other.length)
val list = ArrayList<V>(length)
for (i in 0..length-1) {
@@ -196,7 +196,7 @@ public inline fun <T, K> Comparator<T>.thenByDescending(comparator: Comparator<i
* Creates a comparator using the primary comparator and function to calculate a result of comparison.
*/
@kotlin.internal.InlineOnly
public inline fun <T> Comparator<T>.thenComparator(crossinline comparison: (T, T) -> Int): Comparator<T> {
public inline fun <T> Comparator<T>.thenComparator(crossinline comparison: (a: T, b: T) -> Int): Comparator<T> {
return object : Comparator<T> {
public override fun compare(a: T, b: T): Int {
val previousCompare = this@thenComparator.compare(a, b)
@@ -115,7 +115,7 @@ public fun File.appendText(text: String, charset: Charset = Charsets.UTF_8): Uni
*
* @param action function to process file blocks.
*/
public fun File.forEachBlock(action: (ByteArray, Int) -> Unit): Unit = forEachBlock(DEFAULT_BLOCK_SIZE, action)
public fun File.forEachBlock(action: (buffer: ByteArray, bytesRead: Int) -> Unit): Unit = forEachBlock(DEFAULT_BLOCK_SIZE, action)
/**
* Reads file by byte blocks and calls [action] for each block read.
@@ -126,7 +126,7 @@ public fun File.forEachBlock(action: (ByteArray, Int) -> Unit): Unit = forEachBl
* @param action function to process file blocks.
* @param blockSize size of a block, replaced by 512 if it's less, 4096 by default.
*/
public fun File.forEachBlock(blockSize: Int, action: (ByteArray, Int) -> Unit): Unit {
public fun File.forEachBlock(blockSize: Int, action: (buffer: ByteArray, bytesRead: Int) -> Unit): Unit {
val arr = ByteArray(blockSize.coerceAtLeast(MINIMUM_BLOCK_SIZE))
val fis = FileInputStream(this)