Specify names for parameters of functional types with two or more parameters to ease lambda completion.
#KT-13826
This commit is contained in:
@@ -21,6 +21,6 @@ public interface Comparator<T> {
|
||||
@JsName("compare") fun compare(a: T, b: T): Int
|
||||
}
|
||||
|
||||
public inline fun <T> Comparator(crossinline comparison: (T, T) -> Int): Comparator<T> = object : Comparator<T> {
|
||||
public inline fun <T> Comparator(crossinline comparison: (a: T, b: T) -> Int): Comparator<T> = object : Comparator<T> {
|
||||
override fun compare(a: T, b: T): Int = comparison(a, b)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -616,7 +616,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)
|
||||
}
|
||||
|
||||
@@ -625,7 +625,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)
|
||||
}
|
||||
@@ -1207,7 +1207,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)
|
||||
}
|
||||
|
||||
@@ -1217,7 +1217,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)
|
||||
}
|
||||
|
||||
@@ -1227,7 +1227,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
|
||||
}
|
||||
@@ -1238,7 +1238,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))
|
||||
@@ -1405,7 +1405,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
|
||||
@@ -1417,7 +1417,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)
|
||||
@@ -1427,7 +1427,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)
|
||||
@@ -1444,7 +1444,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)
|
||||
@@ -1469,7 +1469,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)
|
||||
}
|
||||
@@ -1671,7 +1671,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()
|
||||
@@ -1687,7 +1687,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
|
||||
@@ -1701,7 +1701,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.")
|
||||
@@ -1718,7 +1718,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.")
|
||||
@@ -1957,7 +1957,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
|
||||
@@ -1978,7 +1978,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)))
|
||||
|
||||
@@ -312,7 +312,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 })
|
||||
}
|
||||
@@ -322,7 +322,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)
|
||||
}
|
||||
@@ -670,7 +670,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)
|
||||
}
|
||||
|
||||
@@ -680,7 +680,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()
|
||||
}
|
||||
|
||||
@@ -690,7 +690,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
|
||||
}
|
||||
@@ -701,7 +701,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))
|
||||
@@ -817,7 +817,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
|
||||
@@ -829,7 +829,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)
|
||||
@@ -848,7 +848,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)
|
||||
}
|
||||
@@ -1053,7 +1053,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()
|
||||
@@ -1069,7 +1069,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
|
||||
@@ -1255,7 +1255,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)
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +306,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)
|
||||
}
|
||||
|
||||
@@ -315,7 +315,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()
|
||||
}
|
||||
|
||||
@@ -324,7 +324,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)
|
||||
}
|
||||
@@ -727,7 +727,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)
|
||||
}
|
||||
|
||||
@@ -737,7 +737,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)
|
||||
}
|
||||
|
||||
@@ -747,7 +747,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
|
||||
}
|
||||
@@ -758,7 +758,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))
|
||||
@@ -843,7 +843,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
|
||||
@@ -855,7 +855,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)
|
||||
@@ -865,7 +865,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) {
|
||||
@@ -880,7 +880,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) {
|
||||
@@ -902,7 +902,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)
|
||||
}
|
||||
@@ -1022,7 +1022,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]
|
||||
@@ -1038,7 +1038,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]
|
||||
@@ -1051,7 +1051,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--)
|
||||
@@ -1067,7 +1067,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--)
|
||||
@@ -1146,7 +1146,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) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -284,14 +284,14 @@ public header inline fun <T> Iterable<T>.filter(predicate: (T) -> Boolean): List
|
||||
* @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 header inline fun <T> Iterable<T>.filterIndexed(predicate: (Int, T) -> Boolean): List<T>
|
||||
public header inline fun <T> Iterable<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): List<T>
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given [predicate] to the given [destination].
|
||||
* @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 header inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(destination: C, predicate: (Int, T) -> Boolean): C
|
||||
public header inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements that are instances of specified type parameter R.
|
||||
@@ -608,7 +608,7 @@ public header 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 header inline fun <T, R> Iterable<T>.mapIndexed(transform: (Int, T) -> R): List<R>
|
||||
public header inline fun <T, R> Iterable<T>.mapIndexed(transform: (index: Int, T) -> R): List<R>
|
||||
|
||||
/**
|
||||
* Returns a list containing only the non-null results of applying the given [transform] function
|
||||
@@ -616,7 +616,7 @@ public header inline fun <T, R> Iterable<T>.mapIndexed(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 header inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(transform: (Int, T) -> R?): List<R>
|
||||
public header inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): List<R>
|
||||
|
||||
/**
|
||||
* Applies the given [transform] function to each element and its index in the original collection
|
||||
@@ -624,7 +624,7 @@ public header inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(transform: (
|
||||
* @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 header inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(destination: C, transform: (Int, T) -> R?): C
|
||||
public header inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C
|
||||
|
||||
/**
|
||||
* Applies the given [transform] function to each element and its index in the original collection
|
||||
@@ -632,7 +632,7 @@ public header inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.m
|
||||
* @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 header inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(destination: C, transform: (Int, T) -> R): C
|
||||
public header inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C
|
||||
|
||||
/**
|
||||
* Returns a list containing only the non-null results of applying the given [transform] function
|
||||
@@ -736,7 +736,7 @@ public header 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 header inline fun <T, R> Iterable<T>.fold(initial: R, operation: (R, T) -> R): R
|
||||
public header inline fun <T, R> Iterable<T>.fold(initial: R, operation: (acc: R, T) -> R): R
|
||||
|
||||
/**
|
||||
* Accumulates value starting with [initial] value and applying [operation] from left to right
|
||||
@@ -744,12 +744,12 @@ public header inline fun <T, R> Iterable<T>.fold(initial: R, operation: (R, T) -
|
||||
* @param [operation] function that takes the index of an element, current accumulator value
|
||||
* and the element itself, and calculates the next accumulator value.
|
||||
*/
|
||||
public header inline fun <T, R> Iterable<T>.foldIndexed(initial: R, operation: (Int, R, T) -> R): R
|
||||
public header inline fun <T, R> Iterable<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R
|
||||
|
||||
/**
|
||||
* Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.
|
||||
*/
|
||||
public header inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, R) -> R): R
|
||||
public header inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, acc: R) -> R): R
|
||||
|
||||
/**
|
||||
* Accumulates value starting with [initial] value and applying [operation] from right to left
|
||||
@@ -757,7 +757,7 @@ public header inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, 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 header inline fun <T, R> List<T>.foldRightIndexed(initial: R, operation: (Int, T, R) -> R): R
|
||||
public header inline fun <T, R> List<T>.foldRightIndexed(initial: R, operation: (index: Int, T, acc: R) -> R): R
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each element.
|
||||
@@ -770,7 +770,7 @@ public header 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 header inline fun <T> Iterable<T>.forEachIndexed(action: (Int, T) -> Unit): Unit
|
||||
public header inline fun <T> Iterable<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit
|
||||
|
||||
/**
|
||||
* Returns the largest element or `null` if there are no elements.
|
||||
@@ -853,7 +853,7 @@ public header 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 header inline fun <S, T: S> Iterable<T>.reduce(operation: (S, T) -> S): S
|
||||
public header inline fun <S, T: S> Iterable<T>.reduce(operation: (acc: S, T) -> S): S
|
||||
|
||||
/**
|
||||
* Accumulates value starting with the first element and applying [operation] from left to right
|
||||
@@ -861,12 +861,12 @@ public header 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 header inline fun <S, T: S> Iterable<T>.reduceIndexed(operation: (Int, S, T) -> S): S
|
||||
public header inline fun <S, T: S> Iterable<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S
|
||||
|
||||
/**
|
||||
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.
|
||||
*/
|
||||
public header inline fun <S, T: S> List<T>.reduceRight(operation: (T, S) -> S): S
|
||||
public header inline fun <S, T: S> List<T>.reduceRight(operation: (T, acc: S) -> S): S
|
||||
|
||||
/**
|
||||
* Accumulates value starting with last element and applying [operation] from right to left
|
||||
@@ -874,7 +874,7 @@ public header inline fun <S, T: S> List<T>.reduceRight(operation: (T, 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 header inline fun <S, T: S> List<T>.reduceRightIndexed(operation: (Int, T, S) -> S): S
|
||||
public header inline fun <S, T: S> List<T>.reduceRightIndexed(operation: (index: Int, T, acc: S) -> S): S
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the collection.
|
||||
@@ -989,7 +989,7 @@ public header infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<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 header inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (T, R) -> V): List<V>
|
||||
public header inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V>
|
||||
|
||||
/**
|
||||
* Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection.
|
||||
@@ -999,7 +999,7 @@ public header infix fun <T, R> Iterable<T>.zip(other: Iterable<R>): List<Pair<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 header inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (T, R) -> V): List<V>
|
||||
public header inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V>
|
||||
|
||||
/**
|
||||
* Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.
|
||||
|
||||
@@ -146,14 +146,14 @@ public header 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 header fun <T> Sequence<T>.filterIndexed(predicate: (Int, T) -> Boolean): Sequence<T>
|
||||
public header fun <T> Sequence<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): Sequence<T>
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given [predicate] to the given [destination].
|
||||
* @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 header inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterIndexedTo(destination: C, predicate: (Int, T) -> Boolean): C
|
||||
public header inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements that are instances of specified type parameter R.
|
||||
@@ -378,7 +378,7 @@ public header 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 header fun <T, R> Sequence<T>.mapIndexed(transform: (Int, T) -> R): Sequence<R>
|
||||
public header fun <T, R> Sequence<T>.mapIndexed(transform: (index: Int, T) -> R): Sequence<R>
|
||||
|
||||
/**
|
||||
* Returns a sequence containing only the non-null results of applying the given [transform] function
|
||||
@@ -386,7 +386,7 @@ public header fun <T, R> Sequence<T>.mapIndexed(transform: (Int, T) -> R): Seque
|
||||
* @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 header fun <T, R : Any> Sequence<T>.mapIndexedNotNull(transform: (Int, T) -> R?): Sequence<R>
|
||||
public header fun <T, R : Any> Sequence<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): Sequence<R>
|
||||
|
||||
/**
|
||||
* Applies the given [transform] function to each element and its index in the original sequence
|
||||
@@ -394,7 +394,7 @@ public header fun <T, R : Any> Sequence<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 header inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndexedNotNullTo(destination: C, transform: (Int, T) -> R?): C
|
||||
public header inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C
|
||||
|
||||
/**
|
||||
* Applies the given [transform] function to each element and its index in the original sequence
|
||||
@@ -402,7 +402,7 @@ public header inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.m
|
||||
* @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 header inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(destination: C, transform: (Int, T) -> R): C
|
||||
public header inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C
|
||||
|
||||
/**
|
||||
* Returns a sequence containing only the non-null results of applying the given [transform] function
|
||||
@@ -477,7 +477,7 @@ public header 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 header inline fun <T, R> Sequence<T>.fold(initial: R, operation: (R, T) -> R): R
|
||||
public header inline fun <T, R> Sequence<T>.fold(initial: R, operation: (acc: R, T) -> R): R
|
||||
|
||||
/**
|
||||
* Accumulates value starting with [initial] value and applying [operation] from left to right
|
||||
@@ -485,7 +485,7 @@ public header inline fun <T, R> Sequence<T>.fold(initial: R, operation: (R, T) -
|
||||
* @param [operation] function that takes the index of an element, current accumulator value
|
||||
* and the element itself, and calculates the next accumulator value.
|
||||
*/
|
||||
public header inline fun <T, R> Sequence<T>.foldIndexed(initial: R, operation: (Int, R, T) -> R): R
|
||||
public header inline fun <T, R> Sequence<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each element.
|
||||
@@ -497,7 +497,7 @@ public header 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 header inline fun <T> Sequence<T>.forEachIndexed(action: (Int, T) -> Unit): Unit
|
||||
public header inline fun <T> Sequence<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit
|
||||
|
||||
/**
|
||||
* Returns the largest element or `null` if there are no elements.
|
||||
@@ -580,7 +580,7 @@ public header 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 header inline fun <S, T: S> Sequence<T>.reduce(operation: (S, T) -> S): S
|
||||
public header inline fun <S, T: S> Sequence<T>.reduce(operation: (acc: S, T) -> S): S
|
||||
|
||||
/**
|
||||
* Accumulates value starting with the first element and applying [operation] from left to right
|
||||
@@ -588,7 +588,7 @@ public header 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 header inline fun <S, T: S> Sequence<T>.reduceIndexed(operation: (Int, S, T) -> S): S
|
||||
public header inline fun <S, T: S> Sequence<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the sequence.
|
||||
@@ -691,7 +691,7 @@ public header infix fun <T, R> Sequence<T>.zip(other: Sequence<R>): Sequence<Pai
|
||||
/**
|
||||
* 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 header fun <T, R, V> Sequence<T>.zip(other: Sequence<R>, transform: (T, R) -> V): Sequence<V>
|
||||
public header fun <T, R, V> Sequence<T>.zip(other: Sequence<R>, transform: (a: T, b: R) -> V): Sequence<V>
|
||||
|
||||
/**
|
||||
* Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.
|
||||
|
||||
@@ -180,21 +180,21 @@ public header 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 header inline fun CharSequence.filterIndexed(predicate: (Int, Char) -> Boolean): CharSequence
|
||||
public header inline fun CharSequence.filterIndexed(predicate: (index: Int, Char) -> Boolean): CharSequence
|
||||
|
||||
/**
|
||||
* Returns a string containing only those characters from the original string that match the given [predicate].
|
||||
* @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 header inline fun String.filterIndexed(predicate: (Int, Char) -> Boolean): String
|
||||
public header inline fun String.filterIndexed(predicate: (index: Int, Char) -> Boolean): String
|
||||
|
||||
/**
|
||||
* Appends all characters matching the given [predicate] to the given [destination].
|
||||
* @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 header inline fun <C : Appendable> CharSequence.filterIndexedTo(destination: C, predicate: (Int, Char) -> Boolean): C
|
||||
public header inline fun <C : Appendable> CharSequence.filterIndexedTo(destination: C, predicate: (index: Int, Char) -> Boolean): C
|
||||
|
||||
/**
|
||||
* Returns a char sequence containing only those characters from the original char sequence that do not match the given [predicate].
|
||||
@@ -441,7 +441,7 @@ public header 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 header inline fun <R> CharSequence.mapIndexed(transform: (Int, Char) -> R): List<R>
|
||||
public header inline fun <R> CharSequence.mapIndexed(transform: (index: Int, Char) -> R): List<R>
|
||||
|
||||
/**
|
||||
* Returns a list containing only the non-null results of applying the given [transform] function
|
||||
@@ -449,7 +449,7 @@ public header inline fun <R> CharSequence.mapIndexed(transform: (Int, Char) -> 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 header inline fun <R : Any> CharSequence.mapIndexedNotNull(transform: (Int, Char) -> R?): List<R>
|
||||
public header inline fun <R : Any> CharSequence.mapIndexedNotNull(transform: (index: Int, Char) -> R?): List<R>
|
||||
|
||||
/**
|
||||
* Applies the given [transform] function to each character and its index in the original char sequence
|
||||
@@ -457,7 +457,7 @@ public header inline fun <R : Any> CharSequence.mapIndexedNotNull(transform: (In
|
||||
* @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 header inline fun <R : Any, C : MutableCollection<in R>> CharSequence.mapIndexedNotNullTo(destination: C, transform: (Int, Char) -> R?): C
|
||||
public header inline fun <R : Any, C : MutableCollection<in R>> CharSequence.mapIndexedNotNullTo(destination: C, transform: (index: Int, Char) -> R?): C
|
||||
|
||||
/**
|
||||
* Applies the given [transform] function to each character and its index in the original char sequence
|
||||
@@ -465,7 +465,7 @@ public header inline fun <R : Any, C : MutableCollection<in R>> CharSequence.map
|
||||
* @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 header inline fun <R, C : MutableCollection<in R>> CharSequence.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C
|
||||
public header inline fun <R, C : MutableCollection<in R>> CharSequence.mapIndexedTo(destination: C, transform: (index: Int, Char) -> R): C
|
||||
|
||||
/**
|
||||
* Returns a list containing only the non-null results of applying the given [transform] function
|
||||
@@ -519,7 +519,7 @@ public header 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 header inline fun <R> CharSequence.fold(initial: R, operation: (R, Char) -> R): R
|
||||
public header inline fun <R> CharSequence.fold(initial: R, operation: (acc: R, Char) -> R): R
|
||||
|
||||
/**
|
||||
* Accumulates value starting with [initial] value and applying [operation] from left to right
|
||||
@@ -527,12 +527,12 @@ public header inline fun <R> CharSequence.fold(initial: R, operation: (R, 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 header inline fun <R> CharSequence.foldIndexed(initial: R, operation: (Int, R, Char) -> R): R
|
||||
public header inline fun <R> CharSequence.foldIndexed(initial: R, operation: (index: Int, acc: R, Char) -> R): R
|
||||
|
||||
/**
|
||||
* Accumulates value starting with [initial] value and applying [operation] from right to left to each character and current accumulator value.
|
||||
*/
|
||||
public header inline fun <R> CharSequence.foldRight(initial: R, operation: (Char, R) -> R): R
|
||||
public header inline fun <R> CharSequence.foldRight(initial: R, operation: (Char, acc: R) -> R): R
|
||||
|
||||
/**
|
||||
* Accumulates value starting with [initial] value and applying [operation] from right to left
|
||||
@@ -540,7 +540,7 @@ public header inline fun <R> CharSequence.foldRight(initial: R, operation: (Char
|
||||
* @param [operation] function that takes the index of a character, the character itself
|
||||
* and current accumulator value, and calculates the next accumulator value.
|
||||
*/
|
||||
public header inline fun <R> CharSequence.foldRightIndexed(initial: R, operation: (Int, Char, R) -> R): R
|
||||
public header inline fun <R> CharSequence.foldRightIndexed(initial: R, operation: (index: Int, Char, acc: R) -> R): R
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each character.
|
||||
@@ -552,7 +552,7 @@ public header 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 header inline fun CharSequence.forEachIndexed(action: (Int, Char) -> Unit): Unit
|
||||
public header inline fun CharSequence.forEachIndexed(action: (index: Int, Char) -> Unit): Unit
|
||||
|
||||
/**
|
||||
* Returns the largest character or `null` if there are no characters.
|
||||
@@ -603,7 +603,7 @@ public header 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 header inline fun CharSequence.reduce(operation: (Char, Char) -> Char): Char
|
||||
public header inline fun CharSequence.reduce(operation: (acc: Char, Char) -> Char): Char
|
||||
|
||||
/**
|
||||
* Accumulates value starting with the first character and applying [operation] from left to right
|
||||
@@ -611,12 +611,12 @@ public header inline fun CharSequence.reduce(operation: (Char, Char) -> Char): C
|
||||
* @param [operation] function that takes the index of a character, current accumulator value
|
||||
* and the character itself and calculates the next accumulator value.
|
||||
*/
|
||||
public header inline fun CharSequence.reduceIndexed(operation: (Int, Char, Char) -> Char): Char
|
||||
public header inline fun CharSequence.reduceIndexed(operation: (index: Int, acc: Char, Char) -> Char): Char
|
||||
|
||||
/**
|
||||
* Accumulates value starting with last character and applying [operation] from right to left to each character and current accumulator value.
|
||||
*/
|
||||
public header inline fun CharSequence.reduceRight(operation: (Char, Char) -> Char): Char
|
||||
public header inline fun CharSequence.reduceRight(operation: (Char, acc: Char) -> Char): Char
|
||||
|
||||
/**
|
||||
* Accumulates value starting with last character and applying [operation] from right to left
|
||||
@@ -624,7 +624,7 @@ public header inline fun CharSequence.reduceRight(operation: (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 header inline fun CharSequence.reduceRightIndexed(operation: (Int, Char, Char) -> Char): Char
|
||||
public header inline fun CharSequence.reduceRightIndexed(operation: (index: Int, Char, acc: Char) -> Char): Char
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
|
||||
@@ -658,7 +658,7 @@ public header infix fun CharSequence.zip(other: CharSequence): List<Pair<Char, C
|
||||
/**
|
||||
* 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 header inline fun <V> CharSequence.zip(other: CharSequence, transform: (Char, Char) -> V): List<V>
|
||||
public header inline fun <V> CharSequence.zip(other: CharSequence, transform: (a: Char, b: Char) -> V): List<V>
|
||||
|
||||
/**
|
||||
* Creates an [Iterable] instance that wraps the original char sequence returning its characters when being iterated.
|
||||
|
||||
@@ -63,7 +63,7 @@ header interface Comparator<T> {
|
||||
fun compare(a: T, b: T): Int
|
||||
}
|
||||
|
||||
header inline fun <T> Comparator(crossinline comparison: (T, T) -> Int): Comparator<T>
|
||||
header inline fun <T> Comparator(crossinline comparison: (a: T, b: T) -> Int): Comparator<T>
|
||||
|
||||
// From kotlin.kt
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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)))
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
body(Maps) { "return entries.maxWith(comparator)" }
|
||||
}
|
||||
|
||||
templates add f("foldIndexed(initial: R, operation: (Int, R, T) -> R)") {
|
||||
templates add f("foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R)") {
|
||||
inline(true)
|
||||
|
||||
include(CharSequences)
|
||||
@@ -375,7 +375,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("foldRightIndexed(initial: R, operation: (Int, T, R) -> R)") {
|
||||
templates add f("foldRightIndexed(initial: R, operation: (index: Int, T, acc: R) -> R)") {
|
||||
inline(true)
|
||||
|
||||
only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
|
||||
@@ -415,7 +415,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("fold(initial: R, operation: (R, T) -> R)") {
|
||||
templates add f("fold(initial: R, operation: (acc: R, T) -> R)") {
|
||||
inline(true)
|
||||
|
||||
include(CharSequences)
|
||||
@@ -431,7 +431,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("foldRight(initial: R, operation: (T, R) -> R)") {
|
||||
templates add f("foldRight(initial: R, operation: (T, acc: R) -> R)") {
|
||||
inline(true)
|
||||
|
||||
only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
|
||||
@@ -462,7 +462,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("reduceIndexed(operation: (Int, T, T) -> T)") {
|
||||
templates add f("reduceIndexed(operation: (index: Int, acc: T, T) -> T)") {
|
||||
inline(true)
|
||||
only(ArraysOfPrimitives, CharSequences)
|
||||
|
||||
@@ -489,7 +489,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("reduceIndexed(operation: (Int, S, T) -> S)") {
|
||||
templates add f("reduceIndexed(operation: (index: Int, acc: S, T) -> S)") {
|
||||
inline(true)
|
||||
only(ArraysOfObjects, Iterables, Sequences)
|
||||
|
||||
@@ -531,7 +531,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("reduceRightIndexed(operation: (Int, T, T) -> T)") {
|
||||
templates add f("reduceRightIndexed(operation: (index: Int, T, acc: T) -> T)") {
|
||||
inline(true)
|
||||
|
||||
only(CharSequences, ArraysOfPrimitives)
|
||||
@@ -560,7 +560,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("reduceRightIndexed(operation: (Int, T, S) -> S)") {
|
||||
templates add f("reduceRightIndexed(operation: (index: Int, T, acc: S) -> S)") {
|
||||
inline(true)
|
||||
|
||||
only(Lists, ArraysOfObjects)
|
||||
@@ -606,7 +606,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("reduce(operation: (T, T) -> T)") {
|
||||
templates add f("reduce(operation: (acc: T, T) -> T)") {
|
||||
inline(true)
|
||||
only(ArraysOfPrimitives, CharSequences)
|
||||
|
||||
@@ -626,7 +626,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("reduce(operation: (S, T) -> S)") {
|
||||
templates add f("reduce(operation: (acc: S, T) -> S)") {
|
||||
inline(true)
|
||||
only(ArraysOfObjects, Iterables, Sequences)
|
||||
|
||||
@@ -660,7 +660,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("reduceRight(operation: (T, T) -> T)") {
|
||||
templates add f("reduceRight(operation: (T, acc: T) -> T)") {
|
||||
inline(true)
|
||||
|
||||
only(CharSequences, ArraysOfPrimitives)
|
||||
@@ -681,7 +681,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("reduceRight(operation: (T, S) -> S)") {
|
||||
templates add f("reduceRight(operation: (T, acc: S) -> S)") {
|
||||
inline(true)
|
||||
|
||||
only(Lists, ArraysOfObjects)
|
||||
@@ -773,7 +773,7 @@ fun aggregates(): List<GenericFunction> {
|
||||
include(Maps, CharSequences)
|
||||
}
|
||||
|
||||
templates add f("forEachIndexed(action: (Int, T) -> Unit)") {
|
||||
templates add f("forEachIndexed(action: (index: Int, T) -> Unit)") {
|
||||
inline(true)
|
||||
include(CharSequences)
|
||||
doc { f ->
|
||||
|
||||
@@ -468,7 +468,7 @@ fun filtering(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("filterIndexed(predicate: (Int, T) -> Boolean)") {
|
||||
templates add f("filterIndexed(predicate: (index: Int, T) -> Boolean)") {
|
||||
inline(true)
|
||||
|
||||
doc { f ->
|
||||
@@ -506,7 +506,7 @@ fun filtering(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
|
||||
templates add f("filterIndexedTo(destination: C, predicate: (Int, T) -> Boolean)") {
|
||||
templates add f("filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean)") {
|
||||
inline(true)
|
||||
|
||||
include(CharSequences)
|
||||
|
||||
@@ -530,7 +530,7 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("zip(other: Iterable<R>, transform: (T, R) -> V)") {
|
||||
templates add f("zip(other: Iterable<R>, transform: (a: T, b: R) -> V)") {
|
||||
exclude(Sequences)
|
||||
doc {
|
||||
"""
|
||||
@@ -566,7 +566,7 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("zip(other: Array<out R>, transform: (T, R) -> V)") {
|
||||
templates add f("zip(other: Array<out R>, transform: (a: T, b: R) -> V)") {
|
||||
exclude(Sequences)
|
||||
doc {
|
||||
"""
|
||||
@@ -602,7 +602,7 @@ fun generators(): List<GenericFunction> {
|
||||
|
||||
}
|
||||
|
||||
templates add f("zip(other: SELF, transform: (T, T) -> V)") {
|
||||
templates add f("zip(other: SELF, transform: (a: T, b: T) -> V)") {
|
||||
only(ArraysOfPrimitives)
|
||||
doc {
|
||||
"""
|
||||
@@ -624,7 +624,7 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("zip(other: Sequence<R>, transform: (T, R) -> V)") {
|
||||
templates add f("zip(other: Sequence<R>, transform: (a: T, b: R) -> V)") {
|
||||
only(Sequences)
|
||||
doc {
|
||||
"""
|
||||
@@ -641,7 +641,7 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("zip(other: CharSequence, transform: (Char, Char) -> V)") {
|
||||
templates add f("zip(other: CharSequence, transform: (a: Char, b: Char) -> V)") {
|
||||
only(CharSequences)
|
||||
doc {
|
||||
"""
|
||||
|
||||
@@ -23,7 +23,7 @@ fun mapping(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("mapIndexed(transform: (Int, T) -> R)") {
|
||||
templates add f("mapIndexed(transform: (index: Int, T) -> R)") {
|
||||
inline(true)
|
||||
|
||||
doc { f ->
|
||||
@@ -107,7 +107,7 @@ fun mapping(): List<GenericFunction> {
|
||||
|
||||
}
|
||||
|
||||
templates add f("mapIndexedNotNull(transform: (Int, T) -> R?)") {
|
||||
templates add f("mapIndexedNotNull(transform: (index: Int, T) -> R?)") {
|
||||
inline(true)
|
||||
include(CharSequences)
|
||||
exclude(ArraysOfPrimitives)
|
||||
@@ -155,7 +155,7 @@ fun mapping(): List<GenericFunction> {
|
||||
include(Maps, CharSequences)
|
||||
}
|
||||
|
||||
templates add f("mapIndexedTo(destination: C, transform: (Int, T) -> R)") {
|
||||
templates add f("mapIndexedTo(destination: C, transform: (index: Int, T) -> R)") {
|
||||
inline(true)
|
||||
|
||||
doc { f ->
|
||||
@@ -202,7 +202,7 @@ fun mapping(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("mapIndexedNotNullTo(destination: C, transform: (Int, T) -> R?)") {
|
||||
templates add f("mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?)") {
|
||||
inline(true)
|
||||
include(CharSequences)
|
||||
exclude(ArraysOfPrimitives)
|
||||
|
||||
@@ -21,7 +21,7 @@ import templates.Family.*
|
||||
fun specialJS(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
templates add f("sort(noinline comparison: (T, T) -> Int)") {
|
||||
templates add f("sort(noinline comparison: (a: T, b: T) -> Int)") {
|
||||
only(ArraysOfObjects, ArraysOfPrimitives)
|
||||
exclude(PrimitiveType.Boolean)
|
||||
inline(true)
|
||||
|
||||
Reference in New Issue
Block a user