StdLib: Rename method parameters (generated code)

This commit is contained in:
Ilya Gorbunov
2015-11-19 21:11:51 +03:00
parent 7e7a55bbe4
commit 0f70def3db
12 changed files with 713 additions and 700 deletions
File diff suppressed because it is too large Load Diff
+37 -36
View File
@@ -992,13 +992,13 @@ public fun <T> Iterable<T>.toArrayList(): ArrayList<T> {
} }
/** /**
* Appends all elements to the given [collection]. * Appends all elements to the given [destination] collection.
*/ */
public fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(collection: C): C { public fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(destination: C): C {
for (item in this) { for (item in this) {
collection.add(item) destination.add(item)
} }
return collection return destination
} }
/** /**
@@ -1088,18 +1088,18 @@ public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(dest
} }
/** /**
* Returns a map of the elements in original collection grouped by the result of given [toKey] function. * Returns a map of the elements in original collection grouped by the key returned by the given [selector] function.
*/ */
public inline fun <T, K> Iterable<T>.groupBy(toKey: (T) -> K): Map<K, List<T>> { public inline fun <T, K> Iterable<T>.groupBy(selector: (T) -> K): Map<K, List<T>> {
return groupByTo(LinkedHashMap<K, MutableList<T>>(), toKey) return groupByTo(LinkedHashMap<K, MutableList<T>>(), selector)
} }
/** /**
* Appends elements from original collection grouped by the result of given [toKey] function to the given [map]. * Appends elements from original collection grouped by the key returned by the given [selector] function to the given [map].
*/ */
public inline fun <T, K> Iterable<T>.groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K): Map<K, MutableList<T>> { public inline fun <T, K> Iterable<T>.groupByTo(map: MutableMap<K, MutableList<T>>, selector: (T) -> K): Map<K, MutableList<T>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = selector(element)
val list = map.getOrPut(key) { ArrayList<T>() } val list = map.getOrPut(key) { ArrayList<T>() }
list.add(element) list.add(element)
} }
@@ -1193,14 +1193,15 @@ public fun <T> Iterable<T>.distinct(): List<T> {
} }
/** /**
* Returns a list containing only distinct elements from the given collection according to the [keySelector]. * Returns a list containing only elements from the given collection
* having distinct keys returned by the given [selector] function.
* The elements in the resulting list are in the same order as they were in the source collection. * The elements in the resulting list are in the same order as they were in the source collection.
*/ */
public inline fun <T, K> Iterable<T>.distinctBy(keySelector: (T) -> K): List<T> { public inline fun <T, K> Iterable<T>.distinctBy(selector: (T) -> K): List<T> {
val set = HashSet<K>() val set = HashSet<K>()
val list = ArrayList<T>() val list = ArrayList<T>()
for (e in this) { for (e in this) {
val key = keySelector(e) val key = selector(e)
if (set.add(key)) if (set.add(key))
list.add(e) list.add(e)
} }
@@ -1315,18 +1316,18 @@ public inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, R) -> R):
} }
/** /**
* Performs the given [operation] on each element. * Performs the given [action] on each element.
*/ */
public inline fun <T> Iterable<T>.forEach(operation: (T) -> Unit): Unit { public inline fun <T> Iterable<T>.forEach(action: (T) -> Unit): Unit {
for (element in this) operation(element) for (element in this) action(element)
} }
/** /**
* Performs the given [operation] on each element, providing sequential index with the element. * Performs the given [action] on each element, providing sequential index with the element.
*/ */
public inline fun <T> Iterable<T>.forEachIndexed(operation: (Int, T) -> Unit): Unit { public inline fun <T> Iterable<T>.forEachIndexed(action: (Int, T) -> Unit): Unit {
var index = 0 var index = 0
for (item in this) operation(index++, item) for (item in this) action(index++, item)
} }
/** /**
@@ -1346,14 +1347,14 @@ public fun <T : Comparable<T>> Iterable<T>.max(): T? {
/** /**
* Returns the first element yielding the largest value of the given function or `null` if there are no elements. * Returns the first element yielding the largest value of the given function or `null` if there are no elements.
*/ */
public inline fun <R : Comparable<R>, T : Any> Iterable<T>.maxBy(f: (T) -> R): T? { public inline fun <R : Comparable<R>, T : Any> Iterable<T>.maxBy(selector: (T) -> R): T? {
val iterator = iterator() val iterator = iterator()
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var maxElem = iterator.next() var maxElem = iterator.next()
var maxValue = f(maxElem) var maxValue = selector(maxElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (maxValue < v) { if (maxValue < v) {
maxElem = e maxElem = e
maxValue = v maxValue = v
@@ -1379,14 +1380,14 @@ public fun <T : Comparable<T>> Iterable<T>.min(): T? {
/** /**
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements. * Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
*/ */
public inline fun <R : Comparable<R>, T : Any> Iterable<T>.minBy(f: (T) -> R): T? { public inline fun <R : Comparable<R>, T : Any> Iterable<T>.minBy(selector: (T) -> R): T? {
val iterator = iterator() val iterator = iterator()
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var minElem = iterator.next() var minElem = iterator.next()
var minValue = f(minElem) var minValue = selector(minElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (minValue > v) { if (minValue > v) {
minElem = e minElem = e
minValue = v minValue = v
@@ -1438,23 +1439,23 @@ public inline fun <S, T: S> List<T>.reduceRight(operation: (T, S) -> S): S {
} }
/** /**
* Returns the sum of all values produced by [transform] function applied to each element in the collection. * Returns the sum of all values produced by [selector] function applied to each element in the collection.
*/ */
public inline fun <T> Iterable<T>.sumBy(transform: (T) -> Int): Int { public inline fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int {
var sum: Int = 0 var sum: Int = 0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
} }
/** /**
* Returns the sum of all values produced by [transform] function applied to each element in the collection. * Returns the sum of all values produced by [selector] function applied to each element in the collection.
*/ */
public inline fun <T> Iterable<T>.sumByDouble(transform: (T) -> Double): Double { public inline fun <T> Iterable<T>.sumByDouble(selector: (T) -> Double): Double {
var sum: Double = 0.0 var sum: Double = 0.0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
} }
@@ -1631,20 +1632,20 @@ public operator fun <T> Iterable<T>.plus(sequence: Sequence<T>): List<T> {
/** /**
* Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection.
*/ */
public infix fun <T, R> Iterable<T>.zip(array: Array<out R>): List<Pair<T, R>> { public infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>> {
return zip(array) { t1, t2 -> t1 to t2 } return zip(other) { t1, t2 -> t1 to t2 }
} }
/** /**
* Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection.
*/ */
public inline fun <T, R, V> Iterable<T>.zip(array: Array<out R>, transform: (T, R) -> V): List<V> { public inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (T, R) -> V): List<V> {
val arraySize = array.size val arraySize = other.size
val list = ArrayList<V>(Math.min(collectionSizeOrDefault(10), arraySize)) val list = ArrayList<V>(Math.min(collectionSizeOrDefault(10), arraySize))
var i = 0 var i = 0
for (element in this) { for (element in this) {
if (i >= arraySize) break if (i >= arraySize) break
list.add(transform(element, array[i++])) list.add(transform(element, other[i++]))
} }
return list return list
} }
+9 -9
View File
@@ -128,23 +128,23 @@ public inline fun <K, V> Map<K, V>.count(predicate: (Map.Entry<K, V>) -> Boolean
} }
/** /**
* Performs the given [operation] on each entry. * Performs the given [action] on each entry.
*/ */
public inline fun <K, V> Map<K, V>.forEach(operation: (Map.Entry<K, V>) -> Unit): Unit { public inline fun <K, V> Map<K, V>.forEach(action: (Map.Entry<K, V>) -> Unit): Unit {
for (element in this) operation(element) for (element in this) action(element)
} }
/** /**
* Returns the first map entry yielding the largest value of the given function or `null` if there are no entries. * Returns the first map entry yielding the largest value of the given function or `null` if there are no entries.
*/ */
public inline fun <K, V, R : Comparable<R>> Map<K, V>.maxBy(f: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? { public inline fun <K, V, R : Comparable<R>> Map<K, V>.maxBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
val iterator = iterator() val iterator = iterator()
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var maxElem = iterator.next() var maxElem = iterator.next()
var maxValue = f(maxElem) var maxValue = selector(maxElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (maxValue < v) { if (maxValue < v) {
maxElem = e maxElem = e
maxValue = v maxValue = v
@@ -156,14 +156,14 @@ public inline fun <K, V, R : Comparable<R>> Map<K, V>.maxBy(f: (Map.Entry<K, V>)
/** /**
* Returns the first map entry yielding the smallest value of the given function or `null` if there are no entries. * Returns the first map entry yielding the smallest value of the given function or `null` if there are no entries.
*/ */
public inline fun <K, V, R : Comparable<R>> Map<K, V>.minBy(f: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? { public inline fun <K, V, R : Comparable<R>> Map<K, V>.minBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
val iterator = iterator() val iterator = iterator()
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var minElem = iterator.next() var minElem = iterator.next()
var minValue = f(minElem) var minValue = selector(minElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (minValue > v) { if (minValue > v) {
minElem = e minElem = e
minValue = v minValue = v
+37 -36
View File
@@ -488,13 +488,13 @@ public fun <T> Sequence<T>.toArrayList(): ArrayList<T> {
} }
/** /**
* Appends all elements to the given [collection]. * Appends all elements to the given [destination] collection.
*/ */
public fun <T, C : MutableCollection<in T>> Sequence<T>.toCollection(collection: C): C { public fun <T, C : MutableCollection<in T>> Sequence<T>.toCollection(destination: C): C {
for (item in this) { for (item in this) {
collection.add(item) destination.add(item)
} }
return collection return destination
} }
/** /**
@@ -582,18 +582,18 @@ public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(dest
} }
/** /**
* Returns a map of the elements in original sequence grouped by the result of given [toKey] function. * Returns a map of the elements in original sequence grouped by the key returned by the given [selector] function.
*/ */
public inline fun <T, K> Sequence<T>.groupBy(toKey: (T) -> K): Map<K, List<T>> { public inline fun <T, K> Sequence<T>.groupBy(selector: (T) -> K): Map<K, List<T>> {
return groupByTo(LinkedHashMap<K, MutableList<T>>(), toKey) return groupByTo(LinkedHashMap<K, MutableList<T>>(), selector)
} }
/** /**
* Appends elements from original sequence grouped by the result of given [toKey] function to the given [map]. * Appends elements from original sequence grouped by the key returned by the given [selector] function to the given [map].
*/ */
public inline fun <T, K> Sequence<T>.groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K): Map<K, MutableList<T>> { public inline fun <T, K> Sequence<T>.groupByTo(map: MutableMap<K, MutableList<T>>, selector: (T) -> K): Map<K, MutableList<T>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = selector(element)
val list = map.getOrPut(key) { ArrayList<T>() } val list = map.getOrPut(key) { ArrayList<T>() }
list.add(element) list.add(element)
} }
@@ -687,11 +687,12 @@ public fun <T> Sequence<T>.distinct(): Sequence<T> {
} }
/** /**
* Returns a sequence containing only distinct elements from the given sequence according to the [keySelector]. * Returns a sequence containing only elements from the given sequence
* having distinct keys returned by the given [selector] function.
* The elements in the resulting sequence are in the same order as they were in the source sequence. * The elements in the resulting sequence are in the same order as they were in the source sequence.
*/ */
public fun <T, K> Sequence<T>.distinctBy(keySelector: (T) -> K): Sequence<T> { public fun <T, K> Sequence<T>.distinctBy(selector: (T) -> K): Sequence<T> {
return DistinctSequence(this, keySelector) return DistinctSequence(this, selector)
} }
/** /**
@@ -755,18 +756,18 @@ public inline fun <T, R> Sequence<T>.fold(initial: R, operation: (R, T) -> R): R
} }
/** /**
* Performs the given [operation] on each element. * Performs the given [action] on each element.
*/ */
public inline fun <T> Sequence<T>.forEach(operation: (T) -> Unit): Unit { public inline fun <T> Sequence<T>.forEach(action: (T) -> Unit): Unit {
for (element in this) operation(element) for (element in this) action(element)
} }
/** /**
* Performs the given [operation] on each element, providing sequential index with the element. * Performs the given [action] on each element, providing sequential index with the element.
*/ */
public inline fun <T> Sequence<T>.forEachIndexed(operation: (Int, T) -> Unit): Unit { public inline fun <T> Sequence<T>.forEachIndexed(action: (Int, T) -> Unit): Unit {
var index = 0 var index = 0
for (item in this) operation(index++, item) for (item in this) action(index++, item)
} }
/** /**
@@ -786,14 +787,14 @@ public fun <T : Comparable<T>> Sequence<T>.max(): T? {
/** /**
* Returns the first element yielding the largest value of the given function or `null` if there are no elements. * Returns the first element yielding the largest value of the given function or `null` if there are no elements.
*/ */
public inline fun <R : Comparable<R>, T : Any> Sequence<T>.maxBy(f: (T) -> R): T? { public inline fun <R : Comparable<R>, T : Any> Sequence<T>.maxBy(selector: (T) -> R): T? {
val iterator = iterator() val iterator = iterator()
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var maxElem = iterator.next() var maxElem = iterator.next()
var maxValue = f(maxElem) var maxValue = selector(maxElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (maxValue < v) { if (maxValue < v) {
maxElem = e maxElem = e
maxValue = v maxValue = v
@@ -819,14 +820,14 @@ public fun <T : Comparable<T>> Sequence<T>.min(): T? {
/** /**
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements. * Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
*/ */
public inline fun <R : Comparable<R>, T : Any> Sequence<T>.minBy(f: (T) -> R): T? { public inline fun <R : Comparable<R>, T : Any> Sequence<T>.minBy(selector: (T) -> R): T? {
val iterator = iterator() val iterator = iterator()
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var minElem = iterator.next() var minElem = iterator.next()
var minValue = f(minElem) var minValue = selector(minElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (minValue > v) { if (minValue > v) {
minElem = e minElem = e
minValue = v minValue = v
@@ -865,23 +866,23 @@ public inline fun <S, T: S> Sequence<T>.reduce(operation: (S, T) -> S): S {
} }
/** /**
* Returns the sum of all values produced by [transform] function applied to each element in the sequence. * Returns the sum of all values produced by [selector] function applied to each element in the sequence.
*/ */
public inline fun <T> Sequence<T>.sumBy(transform: (T) -> Int): Int { public inline fun <T> Sequence<T>.sumBy(selector: (T) -> Int): Int {
var sum: Int = 0 var sum: Int = 0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
} }
/** /**
* Returns the sum of all values produced by [transform] function applied to each element in the sequence. * Returns the sum of all values produced by [selector] function applied to each element in the sequence.
*/ */
public inline fun <T> Sequence<T>.sumByDouble(transform: (T) -> Double): Double { public inline fun <T> Sequence<T>.sumByDouble(selector: (T) -> Double): Double {
var sum: Double = 0.0 var sum: Double = 0.0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
} }
@@ -1007,18 +1008,18 @@ public operator fun <T> Sequence<T>.plus(sequence: Sequence<T>): Sequence<T> {
} }
/** /**
* Returns a sequence of pairs built from elements of both collections with same indexes. * Returns a sequence of pairs built from elements of both sequences with same indexes.
* Resulting sequence has length of shortest input sequence. * Resulting sequence has length of shortest input sequence.
*/ */
public infix fun <T, R> Sequence<T>.zip(sequence: Sequence<R>): Sequence<Pair<T, R>> { public infix fun <T, R> Sequence<T>.zip(other: Sequence<R>): Sequence<Pair<T, R>> {
return MergingSequence(this, sequence) { t1, t2 -> t1 to t2 } return MergingSequence(this, other) { t1, t2 -> t1 to t2 }
} }
/** /**
* Returns a sequence of values built from elements of both collections with same indexes using provided [transform]. Resulting sequence has length of shortest input sequences. * Returns a sequence of values built from elements of both collections with same indexes using provided [transform]. Resulting sequence has length of shortest input sequences.
*/ */
public fun <T, R, V> Sequence<T>.zip(sequence: Sequence<R>, transform: (T, R) -> V): Sequence<V> { public fun <T, R, V> Sequence<T>.zip(other: Sequence<R>, transform: (T, R) -> V): Sequence<V> {
return MergingSequence(this, sequence, transform) return MergingSequence(this, other, transform)
} }
/** /**
+56 -56
View File
@@ -747,24 +747,24 @@ public fun String.toArrayList(): ArrayList<Char> {
} }
/** /**
* Appends all characters to the given [collection]. * Appends all characters to the given [destination] collection.
*/ */
public fun <C : MutableCollection<in Char>> CharSequence.toCollection(collection: C): C { public fun <C : MutableCollection<in Char>> CharSequence.toCollection(destination: C): C {
for (item in this) { for (item in this) {
collection.add(item) destination.add(item)
} }
return collection return destination
} }
/** /**
* Appends all characters to the given [collection]. * Appends all characters to the given [destination] collection.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun <C : MutableCollection<in Char>> String.toCollection(collection: C): C { public fun <C : MutableCollection<in Char>> String.toCollection(destination: C): C {
for (item in this) { for (item in this) {
collection.add(item) destination.add(item)
} }
return collection return destination
} }
/** /**
@@ -940,26 +940,26 @@ public inline fun <R, C : MutableCollection<in R>> String.flatMapTo(destination:
} }
/** /**
* Returns a map of the characters in original char sequence grouped by the result of given [toKey] function. * Returns a map of the characters in original char sequence grouped by the key returned by the given [selector] function.
*/ */
public inline fun <K> CharSequence.groupBy(toKey: (Char) -> K): Map<K, List<Char>> { public inline fun <K> CharSequence.groupBy(selector: (Char) -> K): Map<K, List<Char>> {
return groupByTo(LinkedHashMap<K, MutableList<Char>>(), toKey) return groupByTo(LinkedHashMap<K, MutableList<Char>>(), selector)
} }
/** /**
* Returns a map of the characters in original string grouped by the result of given [toKey] function. * Returns a map of the characters in original string grouped by the key returned by the given [selector] function.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <K> String.groupBy(toKey: (Char) -> K): Map<K, List<Char>> { public inline fun <K> String.groupBy(selector: (Char) -> K): Map<K, List<Char>> {
return groupByTo(LinkedHashMap<K, MutableList<Char>>(), toKey) return groupByTo(LinkedHashMap<K, MutableList<Char>>(), selector)
} }
/** /**
* Appends characters from original char sequence grouped by the result of given [toKey] function to the given [map]. * Appends characters from original char sequence grouped by the key returned by the given [selector] function to the given [map].
*/ */
public inline fun <K> CharSequence.groupByTo(map: MutableMap<K, MutableList<Char>>, toKey: (Char) -> K): Map<K, MutableList<Char>> { public inline fun <K> CharSequence.groupByTo(map: MutableMap<K, MutableList<Char>>, selector: (Char) -> K): Map<K, MutableList<Char>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = selector(element)
val list = map.getOrPut(key) { ArrayList<Char>() } val list = map.getOrPut(key) { ArrayList<Char>() }
list.add(element) list.add(element)
} }
@@ -967,12 +967,12 @@ public inline fun <K> CharSequence.groupByTo(map: MutableMap<K, MutableList<Char
} }
/** /**
* Appends characters from original string grouped by the result of given [toKey] function to the given [map]. * Appends characters from original string grouped by the key returned by the given [selector] function to the given [map].
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <K> String.groupByTo(map: MutableMap<K, MutableList<Char>>, toKey: (Char) -> K): Map<K, MutableList<Char>> { public inline fun <K> String.groupByTo(map: MutableMap<K, MutableList<Char>>, selector: (Char) -> K): Map<K, MutableList<Char>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = selector(element)
val list = map.getOrPut(key) { ArrayList<Char>() } val list = map.getOrPut(key) { ArrayList<Char>() }
list.add(element) list.add(element)
} }
@@ -1236,35 +1236,35 @@ public inline fun <R> String.foldRight(initial: R, operation: (Char, R) -> R): R
} }
/** /**
* Performs the given [operation] on each character. * Performs the given [action] on each character.
*/ */
public inline fun CharSequence.forEach(operation: (Char) -> Unit): Unit { public inline fun CharSequence.forEach(action: (Char) -> Unit): Unit {
for (element in this) operation(element) for (element in this) action(element)
} }
/** /**
* Performs the given [operation] on each character. * Performs the given [action] on each character.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.forEach(operation: (Char) -> Unit): Unit { public inline fun String.forEach(action: (Char) -> Unit): Unit {
for (element in this) operation(element) for (element in this) action(element)
} }
/** /**
* Performs the given [operation] on each character, providing sequential index with the character. * Performs the given [action] on each character, providing sequential index with the character.
*/ */
public inline fun CharSequence.forEachIndexed(operation: (Int, Char) -> Unit): Unit { public inline fun CharSequence.forEachIndexed(action: (Int, Char) -> Unit): Unit {
var index = 0 var index = 0
for (item in this) operation(index++, item) for (item in this) action(index++, item)
} }
/** /**
* Performs the given [operation] on each character, providing sequential index with the character. * Performs the given [action] on each character, providing sequential index with the character.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.forEachIndexed(operation: (Int, Char) -> Unit): Unit { public inline fun String.forEachIndexed(action: (Int, Char) -> Unit): Unit {
var index = 0 var index = 0
for (item in this) operation(index++, item) for (item in this) action(index++, item)
} }
/** /**
@@ -1297,13 +1297,13 @@ public fun String.max(): Char? {
/** /**
* Returns the first character yielding the largest value of the given function or `null` if there are no characters. * Returns the first character yielding the largest value of the given function or `null` if there are no characters.
*/ */
public inline fun <R : Comparable<R>> CharSequence.maxBy(f: (Char) -> R): Char? { public inline fun <R : Comparable<R>> CharSequence.maxBy(selector: (Char) -> R): Char? {
if (isEmpty()) return null if (isEmpty()) return null
var maxElem = this[0] var maxElem = this[0]
var maxValue = f(maxElem) var maxValue = selector(maxElem)
for (i in 1..lastIndex) { for (i in 1..lastIndex) {
val e = this[i] val e = this[i]
val v = f(e) val v = selector(e)
if (maxValue < v) { if (maxValue < v) {
maxElem = e maxElem = e
maxValue = v maxValue = v
@@ -1316,13 +1316,13 @@ public inline fun <R : Comparable<R>> CharSequence.maxBy(f: (Char) -> R): Char?
* Returns the first character yielding the largest value of the given function or `null` if there are no characters. * 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) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R : Comparable<R>> String.maxBy(f: (Char) -> R): Char? { public inline fun <R : Comparable<R>> String.maxBy(selector: (Char) -> R): Char? {
if (isEmpty()) return null if (isEmpty()) return null
var maxElem = this[0] var maxElem = this[0]
var maxValue = f(maxElem) var maxValue = selector(maxElem)
for (i in 1..lastIndex) { for (i in 1..lastIndex) {
val e = this[i] val e = this[i]
val v = f(e) val v = selector(e)
if (maxValue < v) { if (maxValue < v) {
maxElem = e maxElem = e
maxValue = v maxValue = v
@@ -1361,13 +1361,13 @@ public fun String.min(): Char? {
/** /**
* Returns the first character yielding the smallest value of the given function or `null` if there are no characters. * Returns the first character yielding the smallest value of the given function or `null` if there are no characters.
*/ */
public inline fun <R : Comparable<R>> CharSequence.minBy(f: (Char) -> R): Char? { public inline fun <R : Comparable<R>> CharSequence.minBy(selector: (Char) -> R): Char? {
if (isEmpty()) return null if (isEmpty()) return null
var minElem = this[0] var minElem = this[0]
var minValue = f(minElem) var minValue = selector(minElem)
for (i in 1..lastIndex) { for (i in 1..lastIndex) {
val e = this[i] val e = this[i]
val v = f(e) val v = selector(e)
if (minValue > v) { if (minValue > v) {
minElem = e minElem = e
minValue = v minValue = v
@@ -1380,13 +1380,13 @@ public inline fun <R : Comparable<R>> CharSequence.minBy(f: (Char) -> R): Char?
* Returns the first character yielding the smallest value of the given function or `null` if there are no characters. * 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) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun <R : Comparable<R>> String.minBy(f: (Char) -> R): Char? { public inline fun <R : Comparable<R>> String.minBy(selector: (Char) -> R): Char? {
if (isEmpty()) return null if (isEmpty()) return null
var minElem = this[0] var minElem = this[0]
var minValue = f(minElem) var minValue = selector(minElem)
for (i in 1..lastIndex) { for (i in 1..lastIndex) {
val e = this[i] val e = this[i]
val v = f(e) val v = selector(e)
if (minValue > v) { if (minValue > v) {
minElem = e minElem = e
minValue = v minValue = v
@@ -1484,47 +1484,47 @@ public inline fun String.reduceRight(operation: (Char, Char) -> Char): Char {
} }
/** /**
* Returns the sum of all values produced by [transform] function applied to each character in the char sequence. * Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
*/ */
public inline fun CharSequence.sumBy(transform: (Char) -> Int): Int { public inline fun CharSequence.sumBy(selector: (Char) -> Int): Int {
var sum: Int = 0 var sum: Int = 0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
} }
/** /**
* Returns the sum of all values produced by [transform] function applied to each character in the string. * Returns the sum of all values produced by [selector] function applied to each character in the string.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.sumBy(transform: (Char) -> Int): Int { public inline fun String.sumBy(selector: (Char) -> Int): Int {
var sum: Int = 0 var sum: Int = 0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
} }
/** /**
* Returns the sum of all values produced by [transform] function applied to each character in the char sequence. * Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
*/ */
public inline fun CharSequence.sumByDouble(transform: (Char) -> Double): Double { public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double {
var sum: Double = 0.0 var sum: Double = 0.0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
} }
/** /**
* Returns the sum of all values produced by [transform] function applied to each character in the string. * Returns the sum of all values produced by [selector] function applied to each character in the string.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public inline fun String.sumByDouble(transform: (Char) -> Double): Double { public inline fun String.sumByDouble(selector: (Char) -> Double): Double {
var sum: Double = 0.0 var sum: Double = 0.0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package kotlin.io
/** /**
* Returns the default buffer size when working with buffered streams. * Returns the default buffer size when working with buffered streams.
*/ */
public val defaultBufferSize: Int = 64 * 1024 public val defaultBufferSize: Int = 64 * 1024
/** /**
* Returns the default block size for forEachBlock(). * Returns the default block size for forEachBlock().
@@ -111,34 +111,34 @@ fun aggregates(): List<GenericFunction> {
} }
} }
templates add f("sumBy(transform: (T) -> Int)") { templates add f("sumBy(selector: (T) -> Int)") {
inline(true) inline(true)
include(CharSequences, Strings) include(CharSequences, Strings)
deprecate(Strings) { forBinaryCompatibility } deprecate(Strings) { forBinaryCompatibility }
doc { f -> "Returns the sum of all values produced by [transform] function applied to each ${f.element} in the ${f.collection}." } doc { f -> "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." }
returns("Int") returns("Int")
body { body {
""" """
var sum: Int = 0 var sum: Int = 0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
""" """
} }
} }
templates add f("sumByDouble(transform: (T) -> Double)") { templates add f("sumByDouble(selector: (T) -> Double)") {
inline(true) inline(true)
include(CharSequences, Strings) include(CharSequences, Strings)
deprecate(Strings) { forBinaryCompatibility } deprecate(Strings) { forBinaryCompatibility }
doc { f -> "Returns the sum of all values produced by [transform] function applied to each ${f.element} in the ${f.collection}." } doc { f -> "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." }
returns("Double") returns("Double")
body { body {
""" """
var sum: Double = 0.0 var sum: Double = 0.0
for (element in this) { for (element in this) {
sum += transform(element) sum += selector(element)
} }
return sum return sum
""" """
@@ -177,7 +177,7 @@ fun aggregates(): List<GenericFunction> {
} }
} }
templates add f("minBy(f: (T) -> R)") { templates add f("minBy(selector: (T) -> R)") {
inline(true) inline(true)
doc { f -> "Returns the first ${f.element} yielding the smallest value of the given function or `null` if there are no ${f.element}s." } doc { f -> "Returns the first ${f.element} yielding the smallest value of the given function or `null` if there are no ${f.element}s." }
@@ -190,10 +190,10 @@ fun aggregates(): List<GenericFunction> {
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var minElem = iterator.next() var minElem = iterator.next()
var minValue = f(minElem) var minValue = selector(minElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (minValue > v) { if (minValue > v) {
minElem = e minElem = e
minValue = v minValue = v
@@ -208,10 +208,10 @@ fun aggregates(): List<GenericFunction> {
if (isEmpty()) return null if (isEmpty()) return null
var minElem = this[0] var minElem = this[0]
var minValue = f(minElem) var minValue = selector(minElem)
for (i in 1..lastIndex) { for (i in 1..lastIndex) {
val e = this[i] val e = this[i]
val v = f(e) val v = selector(e)
if (minValue > v) { if (minValue > v) {
minElem = e minElem = e
minValue = v minValue = v
@@ -222,7 +222,7 @@ fun aggregates(): List<GenericFunction> {
} }
} }
templates add f("minBy(f: (T) -> R)") { templates add f("minBy(selector: (T) -> R)") {
inline(true) inline(true)
only(Maps) only(Maps)
@@ -235,10 +235,10 @@ fun aggregates(): List<GenericFunction> {
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var minElem = iterator.next() var minElem = iterator.next()
var minValue = f(minElem) var minValue = selector(minElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (minValue > v) { if (minValue > v) {
minElem = e minElem = e
minValue = v minValue = v
@@ -283,7 +283,7 @@ fun aggregates(): List<GenericFunction> {
} }
} }
templates add f("maxBy(f: (T) -> R)") { templates add f("maxBy(selector: (T) -> R)") {
inline(true) inline(true)
doc { f -> "Returns the first ${f.element} yielding the largest value of the given function or `null` if there are no ${f.element}s." } doc { f -> "Returns the first ${f.element} yielding the largest value of the given function or `null` if there are no ${f.element}s." }
@@ -296,10 +296,10 @@ fun aggregates(): List<GenericFunction> {
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var maxElem = iterator.next() var maxElem = iterator.next()
var maxValue = f(maxElem) var maxValue = selector(maxElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (maxValue < v) { if (maxValue < v) {
maxElem = e maxElem = e
maxValue = v maxValue = v
@@ -314,10 +314,10 @@ fun aggregates(): List<GenericFunction> {
if (isEmpty()) return null if (isEmpty()) return null
var maxElem = this[0] var maxElem = this[0]
var maxValue = f(maxElem) var maxValue = selector(maxElem)
for (i in 1..lastIndex) { for (i in 1..lastIndex) {
val e = this[i] val e = this[i]
val v = f(e) val v = selector(e)
if (maxValue < v) { if (maxValue < v) {
maxElem = e maxElem = e
maxValue = v maxValue = v
@@ -328,7 +328,7 @@ fun aggregates(): List<GenericFunction> {
} }
} }
templates add f("maxBy(f: (T) -> R)") { templates add f("maxBy(selector: (T) -> R)") {
inline(true) inline(true)
only(Maps) only(Maps)
@@ -341,10 +341,10 @@ fun aggregates(): List<GenericFunction> {
if (!iterator.hasNext()) return null if (!iterator.hasNext()) return null
var maxElem = iterator.next() var maxElem = iterator.next()
var maxValue = f(maxElem) var maxValue = selector(maxElem)
while (iterator.hasNext()) { while (iterator.hasNext()) {
val e = iterator.next() val e = iterator.next()
val v = f(e) val v = selector(e)
if (maxValue < v) { if (maxValue < v) {
maxElem = e maxElem = e
maxValue = v maxValue = v
@@ -482,30 +482,30 @@ fun aggregates(): List<GenericFunction> {
} }
} }
templates add f("forEach(operation: (T) -> Unit)") { templates add f("forEach(action: (T) -> Unit)") {
inline(true) inline(true)
doc { f -> "Performs the given [operation] on each ${f.element}." } doc { f -> "Performs the given [action] on each ${f.element}." }
returns("Unit") returns("Unit")
body { body {
""" """
for (element in this) operation(element) for (element in this) action(element)
""" """
} }
deprecate(Strings) { forBinaryCompatibility } deprecate(Strings) { forBinaryCompatibility }
include(Maps, CharSequences, Strings) include(Maps, CharSequences, Strings)
} }
templates add f("forEachIndexed(operation: (Int, T) -> Unit)") { templates add f("forEachIndexed(action: (Int, T) -> Unit)") {
inline(true) inline(true)
deprecate(Strings) { forBinaryCompatibility } deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings) include(CharSequences, Strings)
doc { f -> "Performs the given [operation] on each ${f.element}, providing sequential index with the ${f.element}." } doc { f -> "Performs the given [action] on each ${f.element}, providing sequential index with the ${f.element}." }
returns("Unit") returns("Unit")
body { body {
""" """
var index = 0 var index = 0
for (item in this) operation(index++, item) for (item in this) action(index++, item)
""" """
} }
} }
@@ -480,7 +480,7 @@ fun generators(): List<GenericFunction> {
} }
} }
templates add f("zip(array: Array<out R>, transform: (T, R) -> V)") { templates add f("zip(other: Array<out R>, transform: (T, R) -> V)") {
exclude(Sequences) exclude(Sequences)
doc { doc {
""" """
@@ -493,22 +493,22 @@ fun generators(): List<GenericFunction> {
inline(true) inline(true)
body { body {
""" """
val arraySize = array.size val arraySize = other.size
val list = ArrayList<V>(Math.min(collectionSizeOrDefault(10), arraySize)) val list = ArrayList<V>(Math.min(collectionSizeOrDefault(10), arraySize))
var i = 0 var i = 0
for (element in this) { for (element in this) {
if (i >= arraySize) break if (i >= arraySize) break
list.add(transform(element, array[i++])) list.add(transform(element, other[i++]))
} }
return list return list
""" """
} }
body(ArraysOfObjects, ArraysOfPrimitives) { body(ArraysOfObjects, ArraysOfPrimitives) {
""" """
val size = Math.min(size, array.size) val size = Math.min(size, other.size)
val list = ArrayList<V>(size) val list = ArrayList<V>(size)
for (i in 0..size-1) { for (i in 0..size-1) {
list.add(transform(this[i], array[i])) list.add(transform(this[i], other[i]))
} }
return list return list
""" """
@@ -516,7 +516,7 @@ fun generators(): List<GenericFunction> {
} }
templates add f("zip(array: SELF, transform: (T, T) -> V)") { templates add f("zip(other: SELF, transform: (T, T) -> V)") {
only(ArraysOfPrimitives) only(ArraysOfPrimitives)
doc { doc {
""" """
@@ -528,17 +528,17 @@ fun generators(): List<GenericFunction> {
inline(true) inline(true)
body() { body() {
""" """
val size = Math.min(size, array.size) val size = Math.min(size, other.size)
val list = ArrayList<V>(size) val list = ArrayList<V>(size)
for (i in 0..size-1) { for (i in 0..size-1) {
list.add(transform(this[i], array[i])) list.add(transform(this[i], other[i]))
} }
return list return list
""" """
} }
} }
templates add f("zip(sequence: Sequence<R>, transform: (T, R) -> V)") { templates add f("zip(other: Sequence<R>, transform: (T, R) -> V)") {
only(Sequences) only(Sequences)
doc { doc {
""" """
@@ -550,7 +550,7 @@ fun generators(): List<GenericFunction> {
returns("Sequence<V>") returns("Sequence<V>")
body { body {
""" """
return MergingSequence(this, sequence, transform) return MergingSequence(this, other, transform)
""" """
} }
} }
@@ -614,7 +614,7 @@ fun generators(): List<GenericFunction> {
} }
} }
templates add f("zip(array: Array<out R>)") { templates add f("zip(other: Array<out R>)") {
infix(true) infix(true)
exclude(Sequences) exclude(Sequences)
doc { doc {
@@ -626,12 +626,12 @@ fun generators(): List<GenericFunction> {
returns("List<Pair<T, R>>") returns("List<Pair<T, R>>")
body { body {
""" """
return zip(array) { t1, t2 -> t1 to t2 } return zip(other) { t1, t2 -> t1 to t2 }
""" """
} }
} }
templates add f("zip(array: SELF)") { templates add f("zip(other: SELF)") {
infix(true) infix(true)
only(ArraysOfPrimitives) only(ArraysOfPrimitives)
doc { doc {
@@ -642,17 +642,17 @@ fun generators(): List<GenericFunction> {
returns("List<Pair<T, T>>") returns("List<Pair<T, T>>")
body { body {
""" """
return zip(array) { t1, t2 -> t1 to t2 } return zip(other) { t1, t2 -> t1 to t2 }
""" """
} }
} }
templates add f("zip(sequence: Sequence<R>)") { templates add f("zip(other: Sequence<R>)") {
infix(true) infix(true)
only(Sequences) only(Sequences)
doc { doc {
""" """
Returns a sequence of pairs built from elements of both collections with same indexes. Returns a sequence of pairs built from elements of both sequences with same indexes.
Resulting sequence has length of shortest input sequence. Resulting sequence has length of shortest input sequence.
""" """
} }
@@ -660,7 +660,7 @@ fun generators(): List<GenericFunction> {
returns("Sequence<Pair<T, R>>") returns("Sequence<Pair<T, R>>")
body { body {
""" """
return MergingSequence(this, sequence) { t1, t2 -> t1 to t2 } return MergingSequence(this, other) { t1, t2 -> t1 to t2 }
""" """
} }
} }
@@ -284,29 +284,29 @@ fun mapping(): List<GenericFunction> {
} }
} }
templates add f("groupBy(toKey: (T) -> K)") { templates add f("groupBy(selector: (T) -> K)") {
inline(true) inline(true)
deprecate(Strings) { forBinaryCompatibility } deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings) include(CharSequences, Strings)
doc { f -> "Returns a map of the ${f.element}s in original ${f.collection} grouped by the result of given [toKey] function." } doc { f -> "Returns a map of the ${f.element}s in original ${f.collection} grouped by the key returned by the given [selector] function." }
typeParam("K") typeParam("K")
returns("Map<K, List<T>>") returns("Map<K, List<T>>")
body { "return groupByTo(LinkedHashMap<K, MutableList<T>>(), toKey)" } body { "return groupByTo(LinkedHashMap<K, MutableList<T>>(), selector)" }
} }
templates add f("groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K)") { templates add f("groupByTo(map: MutableMap<K, MutableList<T>>, selector: (T) -> K)") {
inline(true) inline(true)
deprecate(Strings) { forBinaryCompatibility } deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings) include(CharSequences, Strings)
typeParam("K") typeParam("K")
doc { f -> "Appends ${f.element}s from original ${f.collection} grouped by the result of given [toKey] function to the given [map]." } doc { f -> "Appends ${f.element}s from original ${f.collection} grouped by the key returned by the given [selector] function to the given [map]." }
returns("Map<K, MutableList<T>>") returns("Map<K, MutableList<T>>")
body { body {
""" """
for (element in this) { for (element in this) {
val key = toKey(element) val key = selector(element)
val list = map.getOrPut(key) { ArrayList<T>() } val list = map.getOrPut(key) { ArrayList<T>() }
list.add(element) list.add(element)
} }
@@ -50,11 +50,12 @@ fun sets(): List<GenericFunction> {
body(Sequences) { "return this.distinctBy { it }" } body(Sequences) { "return this.distinctBy { it }" }
} }
templates add f("distinctBy(keySelector: (T) -> K)") { templates add f("distinctBy(selector: (T) -> K)") {
exclude(Strings) exclude(Strings)
doc { f -> doc { f ->
""" """
Returns a ${f.mapResult} containing only distinct ${f.element}s from the given ${f.collection} according to the [keySelector]. Returns a ${f.mapResult} containing only ${f.element}s from the given ${f.collection}
having distinct keys returned by the given [selector] function.
The ${f.element}s in the resulting ${f.mapResult} are in the same order as they were in the source ${f.collection}. The ${f.element}s in the resulting ${f.mapResult} are in the same order as they were in the source ${f.collection}.
""" """
@@ -68,7 +69,7 @@ fun sets(): List<GenericFunction> {
val set = HashSet<K>() val set = HashSet<K>()
val list = ArrayList<T>() val list = ArrayList<T>()
for (e in this) { for (e in this) {
val key = keySelector(e) val key = selector(e)
if (set.add(key)) if (set.add(key))
list.add(e) list.add(e)
} }
@@ -80,7 +81,7 @@ fun sets(): List<GenericFunction> {
returns(Sequences) { "Sequence<T>" } returns(Sequences) { "Sequence<T>" }
body(Sequences) { body(Sequences) {
""" """
return DistinctSequence(this, keySelector) return DistinctSequence(this, selector)
""" """
} }
@@ -5,18 +5,18 @@ import templates.Family.*
fun snapshots(): List<GenericFunction> { fun snapshots(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>() val templates = arrayListOf<GenericFunction>()
templates add f("toCollection(collection: C)") { templates add f("toCollection(destination: C)") {
deprecate(Strings) { forBinaryCompatibility } deprecate(Strings) { forBinaryCompatibility }
include(CharSequences, Strings) include(CharSequences, Strings)
doc { f -> "Appends all ${f.element}s to the given [collection]." } doc { f -> "Appends all ${f.element}s to the given [destination] collection." }
returns("C") returns("C")
typeParam("C : MutableCollection<in T>") typeParam("C : MutableCollection<in T>")
body { body {
""" """
for (item in this) { for (item in this) {
collection.add(item) destination.add(item)
} }
return collection return destination
""" """
} }
} }
@@ -244,15 +244,16 @@ fun specialJVM(): List<GenericFunction> {
""" """
} }
// TODO: Use own readonly kotlin.AbstractList
body(ArraysOfPrimitives) { body(ArraysOfPrimitives) {
""" """
return object : AbstractList<T>(), RandomAccess { return object : AbstractList<T>(), RandomAccess {
override val size: Int get() = this@asList.size override val size: Int get() = this@asList.size
override fun isEmpty(): Boolean = this@asList.isEmpty() override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(o: T): Boolean = this@asList.contains(o) override fun contains(element: T): Boolean = this@asList.contains(element)
override fun get(index: Int): T = this@asList[index] override fun get(index: Int): T = this@asList[index]
override fun indexOf(o: T): Int = this@asList.indexOf(o) override fun indexOf(element: T): Int = this@asList.indexOf(element)
override fun lastIndexOf(o: T): Int = this@asList.lastIndexOf(o) override fun lastIndexOf(element: T): Int = this@asList.lastIndexOf(element)
} }
""" """
} }