Use templating in the docs for generated code to name things properly.

This commit is contained in:
Ilya Gorbunov
2015-10-24 07:22:05 +03:00
parent 5b055ac663
commit b4b84a38d5
14 changed files with 771 additions and 734 deletions
File diff suppressed because it is too large Load Diff
+12 -11
View File
@@ -147,7 +147,7 @@ public fun <T> List<T>.elementAtOrNull(index: Int): T? {
}
/**
* Returns the first element matching the given [predicate], or `null` if element was not found.
* Returns the first element matching the given [predicate], or `null` if no such element was found.
*/
public inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? {
return firstOrNull(predicate)
@@ -980,7 +980,7 @@ public inline fun <T, K> Iterable<T>.toMap(selector: (T) -> K): Map<K, T> {
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] from the given collection.
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given collection.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
public inline fun <T, K, V> Iterable<T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
@@ -993,7 +993,8 @@ public inline fun <T, K, V> Iterable<T>.toMap(selector: (T) -> K, transform: (T)
}
/**
* Returns Map containing the values from the given collection indexed by [selector].
* Returns Map containing the elements from the given collection indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
public inline fun <T, K> Iterable<T>.toMapBy(selector: (T) -> K): Map<K, T> {
@@ -1064,14 +1065,14 @@ public inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {
}
/**
* Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
* Returns a list containing the results of applying the given [transform] function to each element and its index in the original collection.
*/
public inline fun <T, R> Iterable<T>.mapIndexed(transform: (Int, T) -> R): List<R> {
return mapIndexedTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)
}
/**
* Appends transformed elements and their indices of the original collection using the given [transform] function
* Appends transformed elements and their indices in the original collection using the given [transform] function
* to the given [destination].
*/
public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(destination: C, transform: (Int, T) -> R): C {
@@ -1310,7 +1311,7 @@ public inline fun <R : Comparable<R>, T : Any> Iterable<T>.minBy(f: (T) -> R): T
}
/**
* Returns `true` if collection has no elements.
* Returns `true` if the collection has no elements.
*/
public fun <T> Iterable<T>.none(): Boolean {
for (element in this) return false
@@ -1352,7 +1353,7 @@ public inline fun <S, T: S> List<T>.reduceRight(operation: (T, S) -> S): S {
}
/**
* Returns the sum of all values produced by [transform] function from elements in the collection.
* Returns the sum of all values produced by [transform] function applied to each element in the collection.
*/
public inline fun <T> Iterable<T>.sumBy(transform: (T) -> Int): Int {
var sum: Int = 0
@@ -1363,7 +1364,7 @@ public inline fun <T> Iterable<T>.sumBy(transform: (T) -> Int): Int {
}
/**
* Returns the sum of all values produced by [transform] function from elements in the collection.
* Returns the sum of all values produced by [transform] function applied to each element in the collection.
*/
public inline fun <T> Iterable<T>.sumByDouble(transform: (T) -> Double): Double {
var sum: Double = 0.0
@@ -1436,9 +1437,9 @@ public operator fun <T> Iterable<T>.minus(sequence: Sequence<T>): List<T> {
}
/**
* Splits the original collection into pair of collections,
* where *first* collection contains elements for which [predicate] yielded `true`,
* while *second* collection contains elements for which [predicate] yielded `false`.
* Splits the original collection into pair of lists,
* where *first* list contains elements for which [predicate] yielded `true`,
* while *second* list contains elements for which [predicate] yielded `false`.
*/
public inline fun <T> Iterable<T>.partition(predicate: (T) -> Boolean): Pair<List<T>, List<T>> {
val first = ArrayList<T>()
+15 -15
View File
@@ -23,14 +23,14 @@ public fun <K, V> Map<K, V>.toList(): List<Pair<K, V>> {
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
* Returns a single list of all elements yielded from results of [transform] function being invoked on each entry of original map.
*/
public inline fun <K, V, R> Map<K, V>.flatMap(transform: (Map.Entry<K, V>) -> Iterable<R>): List<R> {
return flatMapTo(ArrayList<R>(), transform)
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
* Appends all elements yielded from results of [transform] function being invoked on each entry of original map, to the given [destination].
*/
public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.flatMapTo(destination: C, transform: (Map.Entry<K, V>) -> Iterable<R>): C {
for (element in this) {
@@ -41,14 +41,14 @@ public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.flatMapTo(des
}
/**
* Returns a list containing the results of applying the given [transform] function to each element of the original collection.
* Returns a list containing the results of applying the given [transform] function to each entry of the original map.
*/
public inline fun <K, V, R> Map<K, V>.map(transform: (Map.Entry<K, V>) -> R): List<R> {
return mapTo(ArrayList<R>(size()), transform)
}
/**
* Appends transformed elements and their indices of the original collection using the given [transform] function
* Appends transformed entrys and their indices in the original map using the given [transform] function
* to the given [destination].
*/
public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.mapIndexedTo(destination: C, transform: (Int, Map.Entry<K, V>) -> R): C {
@@ -59,7 +59,7 @@ public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.mapIndexedTo(
}
/**
* Appends transformed elements of the original collection using the given [transform] function
* Appends transformed entrys of the original map using the given [transform] function
* to the given [destination].
*/
public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.mapTo(destination: C, transform: (Map.Entry<K, V>) -> R): C {
@@ -69,7 +69,7 @@ public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.mapTo(destina
}
/**
* Returns `true` if all elements match the given [predicate].
* Returns `true` if all entrys match the given [predicate].
*/
public inline fun <K, V> Map<K, V>.all(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
for (element in this) if (!predicate(element)) return false
@@ -77,7 +77,7 @@ public inline fun <K, V> Map<K, V>.all(predicate: (Map.Entry<K, V>) -> Boolean):
}
/**
* Returns `true` if collection has at least one element.
* Returns `true` if map has at least one entry.
*/
public fun <K, V> Map<K, V>.any(): Boolean {
for (element in this) return true
@@ -85,7 +85,7 @@ public fun <K, V> Map<K, V>.any(): Boolean {
}
/**
* Returns `true` if at least one element matches the given [predicate].
* Returns `true` if at least one entry matches the given [predicate].
*/
public inline fun <K, V> Map<K, V>.any(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return true
@@ -93,14 +93,14 @@ public inline fun <K, V> Map<K, V>.any(predicate: (Map.Entry<K, V>) -> Boolean):
}
/**
* Returns the number of elements in this collection.
* Returns the number of entrys in this map.
*/
public fun <K, V> Map<K, V>.count(): Int {
return size()
}
/**
* Returns the number of elements matching the given [predicate].
* Returns the number of entrys matching the given [predicate].
*/
public inline fun <K, V> Map<K, V>.count(predicate: (Map.Entry<K, V>) -> Boolean): Int {
var count = 0
@@ -109,14 +109,14 @@ public inline fun <K, V> Map<K, V>.count(predicate: (Map.Entry<K, V>) -> Boolean
}
/**
* Performs the given [operation] on each element.
* Performs the given [operation] on each entry.
*/
public inline fun <K, V> Map<K, V>.forEach(operation: (Map.Entry<K, V>) -> Unit): Unit {
for (element in this) operation(element)
}
/**
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
* Returns the first map entry yielding the largest value of the given function or `null` if there are no entries.
*/
public inline fun <K, V, R : Comparable<R>> Map<K, V>.maxBy(f: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
val iterator = iterator()
@@ -135,7 +135,7 @@ public inline fun <K, V, R : Comparable<R>> Map<K, V>.maxBy(f: (Map.Entry<K, V>)
}
/**
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
* Returns the first map entry yielding the smallest value of the given function or `null` if there are no entries.
*/
public inline fun <K, V, R : Comparable<R>> Map<K, V>.minBy(f: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
val iterator = iterator()
@@ -154,7 +154,7 @@ public inline fun <K, V, R : Comparable<R>> Map<K, V>.minBy(f: (Map.Entry<K, V>)
}
/**
* Returns `true` if collection has no elements.
* Returns `true` if the map has no entrys.
*/
public fun <K, V> Map<K, V>.none(): Boolean {
for (element in this) return false
@@ -162,7 +162,7 @@ public fun <K, V> Map<K, V>.none(): Boolean {
}
/**
* Returns `true` if no elements match the given [predicate].
* Returns `true` if no entrys match the given [predicate].
*/
public inline fun <K, V> Map<K, V>.none(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return false
+47 -46
View File
@@ -13,7 +13,7 @@ import java.util.*
import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js
/**
* Returns `true` if [element] is found in the collection.
* Returns `true` if [element] is found in the sequence.
*/
public operator fun <T> Sequence<T>.contains(element: @kotlin.internal.NoInfer T): Boolean {
return indexOf(element) >= 0
@@ -30,7 +30,7 @@ public operator fun <T> Sequence<T>.contains(element: T): Boolean {
}
/**
* Returns `true` if [element] is found in the collection.
* Returns `true` if [element] is found in the sequence.
* Allows to overcome type-safety restriction of `contains` that requires to pass an element of type `T`.
*/
@Suppress("NOTHING_TO_INLINE")
@@ -39,14 +39,14 @@ public inline fun Sequence<*>.containsRaw(element: Any?): Boolean {
}
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this sequence.
*/
public fun <T> Sequence<T>.elementAt(index: Int): T {
return elementAtOrElse(index) { throw IndexOutOfBoundsException("Sequence doesn't contain element at index $index.") }
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection.
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this sequence.
*/
public fun <T> Sequence<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {
if (index < 0)
@@ -62,7 +62,7 @@ public fun <T> Sequence<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T)
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this sequence.
*/
public fun <T> Sequence<T>.elementAtOrNull(index: Int): T? {
if (index < 0)
@@ -78,7 +78,7 @@ public fun <T> Sequence<T>.elementAtOrNull(index: Int): T? {
}
/**
* Returns the first element matching the given [predicate], or `null` if element was not found.
* Returns the first element matching the given [predicate], or `null` if no such element was found.
*/
public inline fun <T> Sequence<T>.find(predicate: (T) -> Boolean): T? {
return firstOrNull(predicate)
@@ -93,7 +93,7 @@ public inline fun <T> Sequence<T>.findLast(predicate: (T) -> Boolean): T? {
/**
* Returns first element.
* @throws [NoSuchElementException] if the collection is empty.
* @throws [NoSuchElementException] if the sequence is empty.
*/
public fun <T> Sequence<T>.first(): T {
val iterator = iterator()
@@ -112,7 +112,7 @@ public inline fun <T> Sequence<T>.first(predicate: (T) -> Boolean): T {
}
/**
* Returns the first element, or `null` if the collection is empty.
* Returns the first element, or `null` if the sequence is empty.
*/
public fun <T> Sequence<T>.firstOrNull(): T? {
val iterator = iterator()
@@ -130,7 +130,7 @@ public inline fun <T> Sequence<T>.firstOrNull(predicate: (T) -> Boolean): T? {
}
/**
* Returns first index of [element], or -1 if the collection does not contain element.
* Returns first index of [element], or -1 if the sequence does not contain element.
*/
public fun <T> Sequence<T>.indexOf(element: @kotlin.internal.NoInfer T): Int {
var index = 0
@@ -154,7 +154,7 @@ public fun <T> Sequence<T>.indexOf(element: T): Int {
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element.
* Returns index of the first element matching the given [predicate], or -1 if the sequence does not contain such element.
*/
public inline fun <T> Sequence<T>.indexOfFirst(predicate: (T) -> Boolean): Int {
var index = 0
@@ -167,7 +167,7 @@ public inline fun <T> Sequence<T>.indexOfFirst(predicate: (T) -> Boolean): Int {
}
/**
* Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element.
* Returns index of the last element matching the given [predicate], or -1 if the sequence does not contain such element.
*/
public inline fun <T> Sequence<T>.indexOfLast(predicate: (T) -> Boolean): Int {
var lastIndex = -1
@@ -181,7 +181,7 @@ public inline fun <T> Sequence<T>.indexOfLast(predicate: (T) -> Boolean): Int {
}
/**
* Returns first index of [element], or -1 if the collection does not contain element.
* Returns first index of [element], or -1 if the sequence does not contain element.
* Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`.
*/
@Suppress("NOTHING_TO_INLINE")
@@ -191,7 +191,7 @@ public inline fun Sequence<*>.indexOfRaw(element: Any?): Int {
/**
* Returns the last element.
* @throws [NoSuchElementException] if the collection is empty.
* @throws [NoSuchElementException] if the sequence is empty.
*/
public fun <T> Sequence<T>.last(): T {
val iterator = iterator()
@@ -221,7 +221,7 @@ public inline fun <T> Sequence<T>.last(predicate: (T) -> Boolean): T {
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
* Returns last index of [element], or -1 if the sequence does not contain element.
*/
public fun <T> Sequence<T>.lastIndexOf(element: @kotlin.internal.NoInfer T): Int {
var lastIndex = -1
@@ -246,7 +246,7 @@ public fun <T> Sequence<T>.lastIndexOf(element: T): Int {
}
/**
* Returns last index of [element], or -1 if the collection does not contain element.
* Returns last index of [element], or -1 if the sequence does not contain element.
* Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`.
*/
@Suppress("NOTHING_TO_INLINE")
@@ -255,7 +255,7 @@ public inline fun Sequence<*>.lastIndexOfRaw(element: Any?): Int {
}
/**
* Returns the last element, or `null` if the collection is empty.
* Returns the last element, or `null` if the sequence is empty.
*/
public fun <T> Sequence<T>.lastOrNull(): T? {
val iterator = iterator()
@@ -281,7 +281,7 @@ public inline fun <T> Sequence<T>.lastOrNull(predicate: (T) -> Boolean): T? {
}
/**
* Returns the single element, or throws an exception if the collection is empty or has more than one element.
* Returns the single element, or throws an exception if the sequence is empty or has more than one element.
*/
public fun <T> Sequence<T>.single(): T {
val iterator = iterator()
@@ -311,7 +311,7 @@ public inline fun <T> Sequence<T>.single(predicate: (T) -> Boolean): T {
}
/**
* Returns single element, or `null` if the collection is empty or has more than one element.
* Returns single element, or `null` if the sequence is empty or has more than one element.
*/
public fun <T> Sequence<T>.singleOrNull(): T? {
val iterator = iterator()
@@ -507,7 +507,7 @@ public inline fun <T, K> Sequence<T>.toMap(selector: (T) -> K): Map<K, T> {
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] from the given collection.
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given sequence.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
public inline fun <T, K, V> Sequence<T>.toMap(selector: (T) -> K, transform: (T) -> V): Map<K, V> {
@@ -519,7 +519,8 @@ public inline fun <T, K, V> Sequence<T>.toMap(selector: (T) -> K, transform: (T)
}
/**
* Returns Map containing the values from the given collection indexed by [selector].
* Returns Map containing the elements from the given sequence indexed by the key
* returned from [selector] function applied to each element.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
*/
public inline fun <T, K> Sequence<T>.toMapBy(selector: (T) -> K): Map<K, T> {
@@ -563,14 +564,14 @@ public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(dest
}
/**
* Returns a map of the elements in original collection grouped by the result of given [toKey] function.
* Returns a map of the elements in original sequence grouped by the result of given [toKey] function.
*/
public inline fun <T, K> Sequence<T>.groupBy(toKey: (T) -> K): Map<K, List<T>> {
return groupByTo(LinkedHashMap<K, MutableList<T>>(), toKey)
}
/**
* Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
* Appends elements from original sequence grouped by the result of given [toKey] function to the given [map].
*/
public inline fun <T, K> Sequence<T>.groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K): Map<K, MutableList<T>> {
for (element in this) {
@@ -589,14 +590,14 @@ public fun <T, R> Sequence<T>.map(transform: (T) -> R): Sequence<R> {
}
/**
* Returns a sequence containing the results of applying the given [transform] function to each element and its index of the original sequence.
* Returns a sequence containing the results of applying the given [transform] function to each element and its index in the original sequence.
*/
public fun <T, R> Sequence<T>.mapIndexed(transform: (Int, T) -> R): Sequence<R> {
return TransformingIndexedSequence(this, transform)
}
/**
* Appends transformed elements and their indices of the original collection using the given [transform] function
* Appends transformed elements and their indices in the original sequence using the given [transform] function
* to the given [destination].
*/
public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(destination: C, transform: (Int, T) -> R): C {
@@ -607,7 +608,7 @@ public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(d
}
/**
* Appends transformed elements of the original collection using the given [transform] function
* Appends transformed elements of the original sequence using the given [transform] function
* to the given [destination].
*/
public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapTo(destination: C, transform: (T) -> R): C {
@@ -657,7 +658,7 @@ public inline fun <T> Sequence<T>.all(predicate: (T) -> Boolean): Boolean {
}
/**
* Returns `true` if collection has at least one element.
* Returns `true` if sequence has at least one element.
*/
public fun <T> Sequence<T>.any(): Boolean {
for (element in this) return true
@@ -673,7 +674,7 @@ public inline fun <T> Sequence<T>.any(predicate: (T) -> Boolean): Boolean {
}
/**
* Returns the number of elements in this collection.
* Returns the number of elements in this sequence.
*/
public fun <T> Sequence<T>.count(): Int {
var count = 0
@@ -781,7 +782,7 @@ public inline fun <R : Comparable<R>, T : Any> Sequence<T>.minBy(f: (T) -> R): T
}
/**
* Returns `true` if collection has no elements.
* Returns `true` if the sequence has no elements.
*/
public fun <T> Sequence<T>.none(): Boolean {
for (element in this) return false
@@ -810,7 +811,7 @@ public inline fun <S, T: S> Sequence<T>.reduce(operation: (S, T) -> S): S {
}
/**
* Returns the sum of all values produced by [transform] function from elements in the collection.
* Returns the sum of all values produced by [transform] function applied to each element in the sequence.
*/
public inline fun <T> Sequence<T>.sumBy(transform: (T) -> Int): Int {
var sum: Int = 0
@@ -821,7 +822,7 @@ public inline fun <T> Sequence<T>.sumBy(transform: (T) -> Int): Int {
}
/**
* Returns the sum of all values produced by [transform] function from elements in the collection.
* Returns the sum of all values produced by [transform] function applied to each element in the sequence.
*/
public inline fun <T> Sequence<T>.sumByDouble(transform: (T) -> Double): Double {
var sum: Double = 0.0
@@ -900,9 +901,9 @@ public operator fun <T> Sequence<T>.minus(sequence: Sequence<T>): Sequence<T> {
}
/**
* Splits the original collection into pair of collections,
* where *first* collection contains elements for which [predicate] yielded `true`,
* while *second* collection contains elements for which [predicate] yielded `false`.
* Splits the original sequence into pair of lists,
* where *first* list contains elements for which [predicate] yielded `true`,
* while *second* list contains elements for which [predicate] yielded `false`.
*/
public inline fun <T> Sequence<T>.partition(predicate: (T) -> Boolean): Pair<List<T>, List<T>> {
val first = ArrayList<T>()
@@ -953,7 +954,7 @@ public operator fun <T> Sequence<T>.plus(sequence: Sequence<T>): Sequence<T> {
/**
* Returns a sequence of pairs built from elements of both collections with same indexes.
* Resulting sequence has length of shortest input sequences.
* Resulting sequence has length of shortest input sequence.
*/
public fun <T, R> Sequence<T>.zip(sequence: Sequence<R>): Sequence<Pair<T, R>> {
return MergingSequence(this, sequence) { t1, t2 -> t1 to t2 }
@@ -1037,7 +1038,7 @@ public fun <C : MutableCollection<in R>, R> Sequence<*>.filterIsInstanceTo(desti
}
/**
* Returns an average value of elements in the collection.
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfByte")
public fun Sequence<Byte>.average(): Double {
@@ -1052,7 +1053,7 @@ public fun Sequence<Byte>.average(): Double {
}
/**
* Returns an average value of elements in the collection.
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfDouble")
public fun Sequence<Double>.average(): Double {
@@ -1067,7 +1068,7 @@ public fun Sequence<Double>.average(): Double {
}
/**
* Returns an average value of elements in the collection.
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfFloat")
public fun Sequence<Float>.average(): Double {
@@ -1082,7 +1083,7 @@ public fun Sequence<Float>.average(): Double {
}
/**
* Returns an average value of elements in the collection.
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfInt")
public fun Sequence<Int>.average(): Double {
@@ -1097,7 +1098,7 @@ public fun Sequence<Int>.average(): Double {
}
/**
* Returns an average value of elements in the collection.
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfLong")
public fun Sequence<Long>.average(): Double {
@@ -1112,7 +1113,7 @@ public fun Sequence<Long>.average(): Double {
}
/**
* Returns an average value of elements in the collection.
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfShort")
public fun Sequence<Short>.average(): Double {
@@ -1127,7 +1128,7 @@ public fun Sequence<Short>.average(): Double {
}
/**
* Returns the sum of all elements in the collection.
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfByte")
public fun Sequence<Byte>.sum(): Int {
@@ -1140,7 +1141,7 @@ public fun Sequence<Byte>.sum(): Int {
}
/**
* Returns the sum of all elements in the collection.
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfDouble")
public fun Sequence<Double>.sum(): Double {
@@ -1153,7 +1154,7 @@ public fun Sequence<Double>.sum(): Double {
}
/**
* Returns the sum of all elements in the collection.
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfFloat")
public fun Sequence<Float>.sum(): Float {
@@ -1166,7 +1167,7 @@ public fun Sequence<Float>.sum(): Float {
}
/**
* Returns the sum of all elements in the collection.
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfInt")
public fun Sequence<Int>.sum(): Int {
@@ -1179,7 +1180,7 @@ public fun Sequence<Int>.sum(): Int {
}
/**
* Returns the sum of all elements in the collection.
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfLong")
public fun Sequence<Long>.sum(): Long {
@@ -1192,7 +1193,7 @@ public fun Sequence<Long>.sum(): Long {
}
/**
* Returns the sum of all elements in the collection.
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfShort")
public fun Sequence<Short>.sum(): Int {
+127 -125
View File
@@ -13,14 +13,14 @@ import java.util.*
import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this char sequence.
*/
public fun CharSequence.elementAt(index: Int): Char {
return get(index)
}
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.elementAt(index: Int): Char {
@@ -28,14 +28,14 @@ public fun String.elementAt(index: Int): Char {
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this char sequence.
*/
public inline fun CharSequence.elementAtOrElse(index: Int, defaultValue: (Int) -> Char): Char {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.elementAtOrElse(index: Int, defaultValue: (Int) -> Char): Char {
@@ -43,14 +43,14 @@ public inline fun String.elementAtOrElse(index: Int, defaultValue: (Int) -> Char
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or `null` if the [index] is out of bounds of this char sequence.
*/
public fun CharSequence.elementAtOrNull(index: Int): Char? {
return if (index >= 0 && index <= lastIndex) get(index) else null
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or `null` if the [index] is out of bounds of this string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.elementAtOrNull(index: Int): Char? {
@@ -58,14 +58,14 @@ public fun String.elementAtOrNull(index: Int): Char? {
}
/**
* Returns the first character matching the given [predicate], or `null` if character was not found.
* Returns the first character matching the given [predicate], or `null` if no such character was found.
*/
public inline fun CharSequence.find(predicate: (Char) -> Boolean): Char? {
return firstOrNull(predicate)
}
/**
* Returns the first element matching the given [predicate], or `null` if element was not found.
* Returns the first character matching the given [predicate], or `null` if no such character was found.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.find(predicate: (Char) -> Boolean): Char? {
@@ -80,7 +80,7 @@ public inline fun CharSequence.findLast(predicate: (Char) -> Boolean): Char? {
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
* Returns the last character matching the given [predicate], or `null` if no such character was found.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.findLast(predicate: (Char) -> Boolean): Char? {
@@ -89,7 +89,7 @@ public inline fun String.findLast(predicate: (Char) -> Boolean): Char? {
/**
* Returns first character.
* @throws [NoSuchElementException] if the CharSequence is empty.
* @throws [NoSuchElementException] if the char sequence is empty.
*/
public fun CharSequence.first(): Char {
if (isEmpty())
@@ -98,8 +98,8 @@ public fun CharSequence.first(): Char {
}
/**
* Returns first element.
* @throws [NoSuchElementException] if the collection is empty.
* Returns first character.
* @throws [NoSuchElementException] if the string is empty.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.first(): Char {
@@ -118,8 +118,8 @@ public inline fun CharSequence.first(predicate: (Char) -> Boolean): Char {
}
/**
* Returns the first element matching the given [predicate].
* @throws [NoSuchElementException] if no such element is found.
* Returns the first character matching the given [predicate].
* @throws [NoSuchElementException] if no such character is found.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.first(predicate: (Char) -> Boolean): Char {
@@ -128,14 +128,14 @@ public inline fun String.first(predicate: (Char) -> Boolean): Char {
}
/**
* Returns the first character, or `null` if CharSequence is empty.
* Returns the first character, or `null` if the char sequence is empty.
*/
public fun CharSequence.firstOrNull(): Char? {
return if (isEmpty()) null else this[0]
}
/**
* Returns the first element, or `null` if the collection is empty.
* Returns the first character, or `null` if the string is empty.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.firstOrNull(): Char? {
@@ -151,7 +151,7 @@ public inline fun CharSequence.firstOrNull(predicate: (Char) -> Boolean): Char?
}
/**
* Returns the first element matching the given [predicate], or `null` if element was not found.
* Returns the first character matching the given [predicate], or `null` if character was not found.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.firstOrNull(predicate: (Char) -> Boolean): Char? {
@@ -160,14 +160,14 @@ public inline fun String.firstOrNull(predicate: (Char) -> Boolean): Char? {
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this char sequence.
*/
public inline fun CharSequence.getOrElse(index: Int, defaultValue: (Int) -> Char): Char {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.getOrElse(index: Int, defaultValue: (Int) -> Char): Char {
@@ -175,14 +175,14 @@ public inline fun String.getOrElse(index: Int, defaultValue: (Int) -> Char): Cha
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or `null` if the [index] is out of bounds of this char sequence.
*/
public fun CharSequence.getOrNull(index: Int): Char? {
return if (index >= 0 && index <= lastIndex) get(index) else null
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.
* Returns a character at the given [index] or `null` if the [index] is out of bounds of this string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.getOrNull(index: Int): Char? {
@@ -190,7 +190,7 @@ public fun String.getOrNull(index: Int): Char? {
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element.
* Returns index of the first character matching the given [predicate], or -1 if the char sequence does not contain such character.
*/
public inline fun CharSequence.indexOfFirst(predicate: (Char) -> Boolean): Int {
for (index in indices) {
@@ -202,7 +202,7 @@ public inline fun CharSequence.indexOfFirst(predicate: (Char) -> Boolean): Int {
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element.
* Returns index of the first character matching the given [predicate], or -1 if the string does not contain such character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.indexOfFirst(predicate: (Char) -> Boolean): Int {
@@ -215,7 +215,7 @@ public inline fun String.indexOfFirst(predicate: (Char) -> Boolean): Int {
}
/**
* Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element.
* Returns index of the last character matching the given [predicate], or -1 if the char sequence does not contain such character.
*/
public inline fun CharSequence.indexOfLast(predicate: (Char) -> Boolean): Int {
for (index in indices.reversed()) {
@@ -227,7 +227,7 @@ public inline fun CharSequence.indexOfLast(predicate: (Char) -> Boolean): Int {
}
/**
* Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element.
* Returns index of the last character matching the given [predicate], or -1 if the string does not contain such character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.indexOfLast(predicate: (Char) -> Boolean): Int {
@@ -240,8 +240,8 @@ public inline fun String.indexOfLast(predicate: (Char) -> Boolean): Int {
}
/**
* "Returns the last character.
* @throws [NoSuchElementException] if the string is empty.
* Returns the last character.
* @throws [NoSuchElementException] if the char sequence is empty.
*/
public fun CharSequence.last(): Char {
if (isEmpty())
@@ -250,8 +250,8 @@ public fun CharSequence.last(): Char {
}
/**
* Returns the last element.
* @throws [NoSuchElementException] if the collection is empty.
* Returns the last character.
* @throws [NoSuchElementException] if the string is empty.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.last(): Char {
@@ -261,7 +261,7 @@ public fun String.last(): Char {
}
/**
* "Returns the last character matching the given [predicate].
* Returns the last character matching the given [predicate].
* @throws [NoSuchElementException] if no such character is found.
*/
public inline fun CharSequence.last(predicate: (Char) -> Boolean): Char {
@@ -278,8 +278,8 @@ public inline fun CharSequence.last(predicate: (Char) -> Boolean): Char {
}
/**
* Returns the last element matching the given [predicate].
* @throws [NoSuchElementException] if no such element is found.
* Returns the last character matching the given [predicate].
* @throws [NoSuchElementException] if no such character is found.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.last(predicate: (Char) -> Boolean): Char {
@@ -296,14 +296,14 @@ public inline fun String.last(predicate: (Char) -> Boolean): Char {
}
/**
* Returns the last character, or `null` if the string is empty.
* Returns the last character, or `null` if the char sequence is empty.
*/
public fun CharSequence.lastOrNull(): Char? {
return if (isEmpty()) null else this[length() - 1]
}
/**
* Returns the last element, or `null` if the collection is empty.
* Returns the last character, or `null` if the string is empty.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.lastOrNull(): Char? {
@@ -324,7 +324,7 @@ public inline fun CharSequence.lastOrNull(predicate: (Char) -> Boolean): Char? {
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
* Returns the last character matching the given [predicate], or `null` if no such character was found.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.lastOrNull(predicate: (Char) -> Boolean): Char? {
@@ -338,7 +338,7 @@ public inline fun String.lastOrNull(predicate: (Char) -> Boolean): Char? {
}
/**
* Returns the single character, or throws an exception if the string is empty or has more than one character.
* Returns the single character, or throws an exception if the char sequence is empty or has more than one character.
*/
public fun CharSequence.single(): Char {
return when (length()) {
@@ -349,7 +349,7 @@ public fun CharSequence.single(): Char {
}
/**
* Returns the single element, or throws an exception if the collection is empty or has more than one element.
* Returns the single character, or throws an exception if the string is empty or has more than one character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.single(): Char {
@@ -378,7 +378,7 @@ public inline fun CharSequence.single(predicate: (Char) -> Boolean): Char {
}
/**
* Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.
* Returns the single character matching the given [predicate], or throws exception if there is no or more than one matching character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.single(predicate: (Char) -> Boolean): Char {
@@ -396,14 +396,14 @@ public inline fun String.single(predicate: (Char) -> Boolean): Char {
}
/**
* Returns the single character, or `null` if the string is empty or has more than one character.
* Returns single character, or `null` if the char sequence is empty or has more than one character.
*/
public fun CharSequence.singleOrNull(): Char? {
return if (length() == 1) this[0] else null
}
/**
* Returns single element, or `null` if the collection is empty or has more than one element.
* Returns single character, or `null` if the string is empty or has more than one character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.singleOrNull(): Char? {
@@ -428,7 +428,7 @@ public inline fun CharSequence.singleOrNull(predicate: (Char) -> Boolean): Char?
}
/**
* Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.
* Returns the single character matching the given [predicate], or `null` if character was not found or more than one character was found.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.singleOrNull(predicate: (Char) -> Boolean): Char? {
@@ -704,14 +704,14 @@ public fun String.reversed(): String {
}
/**
* Returns an [ArrayList] of all elements.
* Returns an [ArrayList] of all characters.
*/
public fun CharSequence.toArrayList(): ArrayList<Char> {
return toCollection(ArrayList<Char>(length()))
}
/**
* Returns an [ArrayList] of all elements.
* Returns an [ArrayList] of all characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.toArrayList(): ArrayList<Char> {
@@ -719,7 +719,7 @@ public fun String.toArrayList(): ArrayList<Char> {
}
/**
* Appends all elements to the given [collection].
* Appends all characters to the given [collection].
*/
public fun <C : MutableCollection<in Char>> CharSequence.toCollection(collection: C): C {
for (item in this) {
@@ -729,7 +729,7 @@ public fun <C : MutableCollection<in Char>> CharSequence.toCollection(collection
}
/**
* Appends all elements to the given [collection].
* Appends all characters to the given [collection].
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun <C : MutableCollection<in Char>> String.toCollection(collection: C): C {
@@ -740,14 +740,14 @@ public fun <C : MutableCollection<in Char>> String.toCollection(collection: C):
}
/**
* Returns a [HashSet] of all elements.
* Returns a [HashSet] of all characters.
*/
public fun CharSequence.toHashSet(): HashSet<Char> {
return toCollection(HashSet<Char>(mapCapacity(length())))
}
/**
* Returns a [HashSet] of all elements.
* Returns a [HashSet] of all characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.toHashSet(): HashSet<Char> {
@@ -763,14 +763,14 @@ public fun String.toLinkedList(): LinkedList<Char> {
}
/**
* Returns a [List] containing all elements.
* Returns a [List] containing all characters.
*/
public fun CharSequence.toList(): List<Char> {
return this.toArrayList()
}
/**
* Returns a [List] containing all elements.
* Returns a [List] containing all characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.toList(): List<Char> {
@@ -788,8 +788,8 @@ public inline fun <K> String.toMap(selector: (Char) -> K): Map<K, Char> {
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] from the given collection.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to characters of the given char sequence.
* If any two characters would have the same key returned by [selector] the last one gets added to the map.
*/
public inline fun <K, V> CharSequence.toMap(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
val capacity = (length()/.75f) + 1
@@ -801,8 +801,8 @@ public inline fun <K, V> CharSequence.toMap(selector: (Char) -> K, transform: (C
}
/**
* Returns Map containing the values provided by [transform] and indexed by [selector] from the given collection.
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
* Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to characters of the given string.
* If any two characters would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <K, V> String.toMap(selector: (Char) -> K, transform: (Char) -> V): Map<K, V> {
@@ -815,8 +815,9 @@ public inline fun <K, V> String.toMap(selector: (Char) -> K, transform: (Char) -
}
/**
* Returns Map containing the values from the given collection indexed by [selector].
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
* Returns Map containing the characters from the given char sequence indexed by the key
* returned from [selector] function applied to each character.
* If any two characters would have the same key returned by [selector] the last one gets added to the map.
*/
public inline fun <K> CharSequence.toMapBy(selector: (Char) -> K): Map<K, Char> {
val capacity = (length()/.75f) + 1
@@ -828,8 +829,9 @@ public inline fun <K> CharSequence.toMapBy(selector: (Char) -> K): Map<K, Char>
}
/**
* Returns Map containing the values from the given collection indexed by [selector].
* If any two elements would have the same key returned by [selector] the last one gets added to the map.
* Returns Map containing the characters from the given string indexed by the key
* returned from [selector] function applied to each character.
* If any two characters would have the same key returned by [selector] the last one gets added to the map.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <K> String.toMapBy(selector: (Char) -> K): Map<K, Char> {
@@ -842,14 +844,14 @@ public inline fun <K> String.toMapBy(selector: (Char) -> K): Map<K, Char> {
}
/**
* Returns a [Set] of all elements.
* Returns a [Set] of all characters.
*/
public fun CharSequence.toSet(): Set<Char> {
return toCollection(LinkedHashSet<Char>(mapCapacity(length())))
}
/**
* Returns a [Set] of all elements.
* Returns a [Set] of all characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.toSet(): Set<Char> {
@@ -857,14 +859,14 @@ public fun String.toSet(): Set<Char> {
}
/**
* Returns a [SortedSet] of all elements.
* Returns a [SortedSet] of all characters.
*/
public fun CharSequence.toSortedSet(): SortedSet<Char> {
return toCollection(TreeSet<Char>())
}
/**
* Returns a [SortedSet] of all elements.
* Returns a [SortedSet] of all characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.toSortedSet(): SortedSet<Char> {
@@ -872,14 +874,14 @@ public fun String.toSortedSet(): SortedSet<Char> {
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
* Returns a single list of all elements yielded from results of [transform] function being invoked on each character of original char sequence.
*/
public inline fun <R> CharSequence.flatMap(transform: (Char) -> Iterable<R>): List<R> {
return flatMapTo(ArrayList<R>(), transform)
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
* Returns a single list of all elements yielded from results of [transform] function being invoked on each character of original string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R> String.flatMap(transform: (Char) -> Iterable<R>): List<R> {
@@ -887,7 +889,7 @@ public inline fun <R> String.flatMap(transform: (Char) -> Iterable<R>): List<R>
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
* Appends all elements yielded from results of [transform] function being invoked on each character of original char sequence, to the given [destination].
*/
public inline fun <R, C : MutableCollection<in R>> CharSequence.flatMapTo(destination: C, transform: (Char) -> Iterable<R>): C {
for (element in this) {
@@ -898,7 +900,7 @@ public inline fun <R, C : MutableCollection<in R>> CharSequence.flatMapTo(destin
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].
* Appends all elements yielded from results of [transform] function being invoked on each character of original string, to the given [destination].
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R, C : MutableCollection<in R>> String.flatMapTo(destination: C, transform: (Char) -> Iterable<R>): C {
@@ -910,14 +912,14 @@ public inline fun <R, C : MutableCollection<in R>> String.flatMapTo(destination:
}
/**
* Returns a map of the elements in original collection grouped by the result of given [toKey] function.
* Returns a map of the characters in original char sequence grouped by the result of given [toKey] function.
*/
public inline fun <K> CharSequence.groupBy(toKey: (Char) -> K): Map<K, List<Char>> {
return groupByTo(LinkedHashMap<K, MutableList<Char>>(), toKey)
}
/**
* Returns a map of the elements in original collection grouped by the result of given [toKey] function.
* Returns a map of the characters in original string grouped by the result of given [toKey] function.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <K> String.groupBy(toKey: (Char) -> K): Map<K, List<Char>> {
@@ -925,7 +927,7 @@ public inline fun <K> String.groupBy(toKey: (Char) -> K): Map<K, List<Char>> {
}
/**
* Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
* Appends characters from original char sequence grouped by the result of given [toKey] function to the given [map].
*/
public inline fun <K> CharSequence.groupByTo(map: MutableMap<K, MutableList<Char>>, toKey: (Char) -> K): Map<K, MutableList<Char>> {
for (element in this) {
@@ -937,7 +939,7 @@ public inline fun <K> CharSequence.groupByTo(map: MutableMap<K, MutableList<Char
}
/**
* Appends elements from original collection grouped by the result of given [toKey] function to the given [map].
* Appends characters from original string grouped by the result of given [toKey] function to the given [map].
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <K> String.groupByTo(map: MutableMap<K, MutableList<Char>>, toKey: (Char) -> K): Map<K, MutableList<Char>> {
@@ -950,14 +952,14 @@ public inline fun <K> String.groupByTo(map: MutableMap<K, MutableList<Char>>, to
}
/**
* Returns a list containing the results of applying the given [transform] function to each element of the original collection.
* Returns a list containing the results of applying the given [transform] function to each character of the original char sequence.
*/
public inline fun <R> CharSequence.map(transform: (Char) -> R): List<R> {
return mapTo(ArrayList<R>(length()), transform)
}
/**
* Returns a list containing the results of applying the given [transform] function to each element of the original collection.
* Returns a list containing the results of applying the given [transform] function to each character of the original string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R> String.map(transform: (Char) -> R): List<R> {
@@ -965,14 +967,14 @@ public inline fun <R> String.map(transform: (Char) -> R): List<R> {
}
/**
* Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
* Returns a list containing the results of applying the given [transform] function to each character and its index in the original char sequence.
*/
public inline fun <R> CharSequence.mapIndexed(transform: (Int, Char) -> R): List<R> {
return mapIndexedTo(ArrayList<R>(length()), transform)
}
/**
* Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection.
* Returns a list containing the results of applying the given [transform] function to each character and its index in the original string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R> String.mapIndexed(transform: (Int, Char) -> R): List<R> {
@@ -980,7 +982,7 @@ public inline fun <R> String.mapIndexed(transform: (Int, Char) -> R): List<R> {
}
/**
* Appends transformed elements and their indices of the original collection using the given [transform] function
* Appends transformed characters and their indices in the original char sequence using the given [transform] function
* to the given [destination].
*/
public inline fun <R, C : MutableCollection<in R>> CharSequence.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C {
@@ -991,7 +993,7 @@ public inline fun <R, C : MutableCollection<in R>> CharSequence.mapIndexedTo(des
}
/**
* Appends transformed elements and their indices of the original collection using the given [transform] function
* Appends transformed characters and their indices in the original string using the given [transform] function
* to the given [destination].
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
@@ -1003,7 +1005,7 @@ public inline fun <R, C : MutableCollection<in R>> String.mapIndexedTo(destinati
}
/**
* Appends transformed elements of the original collection using the given [transform] function
* Appends transformed characters of the original char sequence using the given [transform] function
* to the given [destination].
*/
public inline fun <R, C : MutableCollection<in R>> CharSequence.mapTo(destination: C, transform: (Char) -> R): C {
@@ -1013,7 +1015,7 @@ public inline fun <R, C : MutableCollection<in R>> CharSequence.mapTo(destinatio
}
/**
* Appends transformed elements of the original collection using the given [transform] function
* Appends transformed characters of the original string using the given [transform] function
* to the given [destination].
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
@@ -1024,14 +1026,14 @@ public inline fun <R, C : MutableCollection<in R>> String.mapTo(destination: C,
}
/**
* Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
* Returns a lazy [Iterable] of [IndexedValue] for each character of the original char sequence.
*/
public fun CharSequence.withIndex(): Iterable<IndexedValue<Char>> {
return IndexingIterable { iterator() }
}
/**
* Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.
* Returns a lazy [Iterable] of [IndexedValue] for each character of the original string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.withIndex(): Iterable<IndexedValue<Char>> {
@@ -1039,7 +1041,7 @@ public fun String.withIndex(): Iterable<IndexedValue<Char>> {
}
/**
* Returns `true` if all elements match the given [predicate].
* Returns `true` if all characters match the given [predicate].
*/
public inline fun CharSequence.all(predicate: (Char) -> Boolean): Boolean {
for (element in this) if (!predicate(element)) return false
@@ -1047,7 +1049,7 @@ public inline fun CharSequence.all(predicate: (Char) -> Boolean): Boolean {
}
/**
* Returns `true` if all elements match the given [predicate].
* Returns `true` if all characters match the given [predicate].
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.all(predicate: (Char) -> Boolean): Boolean {
@@ -1056,7 +1058,7 @@ public inline fun String.all(predicate: (Char) -> Boolean): Boolean {
}
/**
* Returns `true` if collection has at least one element.
* Returns `true` if char sequence has at least one character.
*/
public fun CharSequence.any(): Boolean {
for (element in this) return true
@@ -1064,7 +1066,7 @@ public fun CharSequence.any(): Boolean {
}
/**
* Returns `true` if collection has at least one element.
* Returns `true` if string has at least one character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.any(): Boolean {
@@ -1073,7 +1075,7 @@ public fun String.any(): Boolean {
}
/**
* Returns `true` if at least one element matches the given [predicate].
* Returns `true` if at least one character matches the given [predicate].
*/
public inline fun CharSequence.any(predicate: (Char) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return true
@@ -1081,7 +1083,7 @@ public inline fun CharSequence.any(predicate: (Char) -> Boolean): Boolean {
}
/**
* Returns `true` if at least one element matches the given [predicate].
* Returns `true` if at least one character matches the given [predicate].
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.any(predicate: (Char) -> Boolean): Boolean {
@@ -1090,14 +1092,14 @@ public inline fun String.any(predicate: (Char) -> Boolean): Boolean {
}
/**
* Returns the length of this string.
* Returns the length of this char sequence.
*/
public fun CharSequence.count(): Int {
return length()
}
/**
* Returns the number of elements in this collection.
* Returns the number of characters in this string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.count(): Int {
@@ -1105,7 +1107,7 @@ public fun String.count(): Int {
}
/**
* Returns the number of elements matching the given [predicate].
* Returns the number of characters matching the given [predicate].
*/
public inline fun CharSequence.count(predicate: (Char) -> Boolean): Int {
var count = 0
@@ -1114,7 +1116,7 @@ public inline fun CharSequence.count(predicate: (Char) -> Boolean): Int {
}
/**
* Returns the number of elements matching the given [predicate].
* Returns the number of characters matching the given [predicate].
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.count(predicate: (Char) -> Boolean): Int {
@@ -1124,7 +1126,7 @@ public inline fun String.count(predicate: (Char) -> Boolean): Int {
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
* 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 {
var accumulator = initial
@@ -1133,7 +1135,7 @@ public inline fun <R> CharSequence.fold(initial: R, operation: (R, Char) -> R):
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R> String.fold(initial: R, operation: (R, Char) -> R): R {
@@ -1143,7 +1145,7 @@ public inline fun <R> String.fold(initial: R, operation: (R, Char) -> R): R {
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.
* 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 {
var index = lastIndex
@@ -1155,7 +1157,7 @@ public inline fun <R> CharSequence.foldRight(initial: R, operation: (Char, R) ->
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with [initial] value and applying [operation] from right to left to each character and current accumulator value.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R> String.foldRight(initial: R, operation: (Char, R) -> R): R {
@@ -1168,14 +1170,14 @@ public inline fun <R> String.foldRight(initial: R, operation: (Char, R) -> R): R
}
/**
* Performs the given [operation] on each element.
* Performs the given [operation] on each character.
*/
public inline fun CharSequence.forEach(operation: (Char) -> Unit): Unit {
for (element in this) operation(element)
}
/**
* Performs the given [operation] on each element.
* Performs the given [operation] on each character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.forEach(operation: (Char) -> Unit): Unit {
@@ -1183,7 +1185,7 @@ public inline fun String.forEach(operation: (Char) -> Unit): Unit {
}
/**
* Performs the given [operation] on each element, providing sequential index with the element.
* Performs the given [operation] on each character, providing sequential index with the character.
*/
public inline fun CharSequence.forEachIndexed(operation: (Int, Char) -> Unit): Unit {
var index = 0
@@ -1191,7 +1193,7 @@ public inline fun CharSequence.forEachIndexed(operation: (Int, Char) -> Unit): U
}
/**
* Performs the given [operation] on each element, providing sequential index with the element.
* Performs the given [operation] on each character, providing sequential index with the character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.forEachIndexed(operation: (Int, Char) -> Unit): Unit {
@@ -1200,7 +1202,7 @@ public inline fun String.forEachIndexed(operation: (Int, Char) -> Unit): Unit {
}
/**
* Returns the largest element or `null` if there are no elements.
* Returns the largest character or `null` if there are no characters.
*/
public fun CharSequence.max(): Char? {
if (isEmpty()) return null
@@ -1213,7 +1215,7 @@ public fun CharSequence.max(): Char? {
}
/**
* Returns the largest element or `null` if there are no elements.
* Returns the largest character or `null` if there are no characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.max(): Char? {
@@ -1227,7 +1229,7 @@ public fun String.max(): Char? {
}
/**
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
* Returns the first character yielding the largest value of the given function or `null` if there are no characters.
*/
public inline fun <R : Comparable<R>> CharSequence.maxBy(f: (Char) -> R): Char? {
if (isEmpty()) return null
@@ -1245,7 +1247,7 @@ public inline fun <R : Comparable<R>> CharSequence.maxBy(f: (Char) -> R): Char?
}
/**
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
* Returns the first character yielding the largest value of the given function or `null` if there are no characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R : Comparable<R>> String.maxBy(f: (Char) -> R): Char? {
@@ -1264,7 +1266,7 @@ public inline fun <R : Comparable<R>> String.maxBy(f: (Char) -> R): Char? {
}
/**
* Returns the smallest element or `null` if there are no elements.
* Returns the smallest character or `null` if there are no characters.
*/
public fun CharSequence.min(): Char? {
if (isEmpty()) return null
@@ -1277,7 +1279,7 @@ public fun CharSequence.min(): Char? {
}
/**
* Returns the smallest element or `null` if there are no elements.
* Returns the smallest character or `null` if there are no characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.min(): Char? {
@@ -1291,7 +1293,7 @@ public fun String.min(): Char? {
}
/**
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
* Returns the first character yielding the smallest value of the given function or `null` if there are no characters.
*/
public inline fun <R : Comparable<R>> CharSequence.minBy(f: (Char) -> R): Char? {
if (isEmpty()) return null
@@ -1309,7 +1311,7 @@ public inline fun <R : Comparable<R>> CharSequence.minBy(f: (Char) -> R): Char?
}
/**
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
* Returns the first character yielding the smallest value of the given function or `null` if there are no characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R : Comparable<R>> String.minBy(f: (Char) -> R): Char? {
@@ -1328,7 +1330,7 @@ public inline fun <R : Comparable<R>> String.minBy(f: (Char) -> R): Char? {
}
/**
* Returns `true` if collection has no elements.
* Returns `true` if the char sequence has no characters.
*/
public fun CharSequence.none(): Boolean {
for (element in this) return false
@@ -1336,7 +1338,7 @@ public fun CharSequence.none(): Boolean {
}
/**
* Returns `true` if collection has no elements.
* Returns `true` if the string has no characters.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.none(): Boolean {
@@ -1345,7 +1347,7 @@ public fun String.none(): Boolean {
}
/**
* Returns `true` if no elements match the given [predicate].
* Returns `true` if no characters match the given [predicate].
*/
public inline fun CharSequence.none(predicate: (Char) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return false
@@ -1353,7 +1355,7 @@ public inline fun CharSequence.none(predicate: (Char) -> Boolean): Boolean {
}
/**
* Returns `true` if no elements match the given [predicate].
* Returns `true` if no characters match the given [predicate].
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.none(predicate: (Char) -> Boolean): Boolean {
@@ -1362,7 +1364,7 @@ public inline fun String.none(predicate: (Char) -> Boolean): Boolean {
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
* 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 {
val iterator = this.iterator()
@@ -1375,7 +1377,7 @@ public inline fun CharSequence.reduce(operation: (Char, Char) -> Char): Char {
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with the first character and applying [operation] from left to right to current accumulator value and each character.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.reduce(operation: (Char, Char) -> Char): Char {
@@ -1389,7 +1391,7 @@ public inline fun String.reduce(operation: (Char, Char) -> Char): Char {
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.
* 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 {
var index = lastIndex
@@ -1402,7 +1404,7 @@ public inline fun CharSequence.reduceRight(operation: (Char, Char) -> Char): Cha
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with last character and applying [operation] from right to left to each character and current accumulator value.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.reduceRight(operation: (Char, Char) -> Char): Char {
@@ -1416,7 +1418,7 @@ public inline fun String.reduceRight(operation: (Char, Char) -> Char): Char {
}
/**
* Returns the sum of all values produced by [transform] function from characters in the string.
* Returns the sum of all values produced by [transform] function applied to each character in the char sequence.
*/
public inline fun CharSequence.sumBy(transform: (Char) -> Int): Int {
var sum: Int = 0
@@ -1427,7 +1429,7 @@ public inline fun CharSequence.sumBy(transform: (Char) -> Int): Int {
}
/**
* Returns the sum of all values produced by [transform] function from elements in the collection.
* Returns the sum of all values produced by [transform] function applied to each character in the string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.sumBy(transform: (Char) -> Int): Int {
@@ -1439,7 +1441,7 @@ public inline fun String.sumBy(transform: (Char) -> Int): Int {
}
/**
* Returns the sum of all values produced by [transform] function from characters in the string.
* Returns the sum of all values produced by [transform] function applied to each character in the char sequence.
*/
public inline fun CharSequence.sumByDouble(transform: (Char) -> Double): Double {
var sum: Double = 0.0
@@ -1450,7 +1452,7 @@ public inline fun CharSequence.sumByDouble(transform: (Char) -> Double): Double
}
/**
* Returns the sum of all values produced by [transform] function from elements in the collection.
* Returns the sum of all values produced by [transform] function applied to each character in the string.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.sumByDouble(transform: (Char) -> Double): Double {
@@ -1462,7 +1464,7 @@ public inline fun String.sumByDouble(transform: (Char) -> Double): Double {
}
/**
* Splits the original string into pair of strings,
* Splits the original char sequence into pair of strings,
* where *first* string contains characters for which [predicate] yielded `true`,
* while *second* string contains characters for which [predicate] yielded `false`.
*/
@@ -1480,9 +1482,9 @@ public inline fun CharSequence.partition(predicate: (Char) -> Boolean): Pair<Str
}
/**
* Splits the original collection into pair of collections,
* where *first* collection contains elements for which [predicate] yielded `true`,
* while *second* collection contains elements for which [predicate] yielded `false`.
* Splits the original string into pair of lists,
* where *first* list contains elements for which [predicate] yielded `true`,
* while *second* list contains elements for which [predicate] yielded `false`.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.partition(predicate: (Char) -> Boolean): Pair<String, String> {
@@ -1499,14 +1501,14 @@ public inline fun String.partition(predicate: (Char) -> Boolean): Pair<String, S
}
/**
* Returns a list of pairs built from characters of both strings with same indexes. List has length of shortest collection.
* Returns a list of pairs built from characters of both char sequences with same indexes. List has length of shortest char sequence.
*/
public fun CharSequence.zip(other: String): List<Pair<Char, Char>> {
return zip(other) { c1, c2 -> c1 to c2 }
}
/**
* Returns a list of pairs built from characters of both strings with same indexes. List has length of shortest collection.
* Returns a list of pairs built from characters of both char sequences with same indexes. List has length of shortest char sequence.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.zip(other: String): List<Pair<Char, Char>> {
@@ -1514,7 +1516,7 @@ public fun String.zip(other: String): List<Pair<Char, Char>> {
}
/**
* Returns a list of values built from characters of both strings with same indexes using provided [transform]. List has length of shortest string.
* 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: String, transform: (Char, Char) -> V): List<V> {
val length = Math.min(this.length(), other.length())
@@ -1526,7 +1528,7 @@ public inline fun <V> CharSequence.zip(other: String, transform: (Char, Char) ->
}
/**
* Returns a list of values built from characters of both strings with same indexes using provided [transform]. List has length of shortest string.
* 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.
*/
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <V> String.zip(other: String, transform: (Char, Char) -> V): List<V> {