Replace .. with until or indices where appropriate
Replace indices.reversed() with lastIndex..0 as it is not optimized in JS yet
This commit is contained in:
@@ -158,7 +158,7 @@ internal class BoxedChar(val c: Int) : Comparable<Int> {
|
||||
@kotlin.internal.InlineOnly
|
||||
internal inline fun <T> concat(args: Array<T>): T {
|
||||
val typed = js("Array")(args.size)
|
||||
for (i in 0..args.size - 1) {
|
||||
for (i in args.indices) {
|
||||
val arr = args[i]
|
||||
if (arr !is Array<*>) {
|
||||
typed[i] = js("[]").slice.call(arr)
|
||||
@@ -196,15 +196,15 @@ internal fun <T> primitiveArrayConcat(a: T, b: T): T {
|
||||
}
|
||||
else {
|
||||
var size = 0
|
||||
for (i in 0..args.size - 1) {
|
||||
for (i in args.indices) {
|
||||
size += args[i].asDynamic().length as Int
|
||||
}
|
||||
val result = js("new a.constructor(size)")
|
||||
kotlin.copyArrayType(a, result)
|
||||
size = 0
|
||||
for (i in 0..args.size - 1) {
|
||||
for (i in args.indices) {
|
||||
val arr = args[i].asDynamic()
|
||||
for (j in 0..arr.length - 1) {
|
||||
for (j in 0 until arr.length) {
|
||||
result[size++] = arr[j]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ internal class InternalHashCodeMap<K, V>(override val equality: EqualityComparat
|
||||
}
|
||||
else {
|
||||
val chain: Array<MutableEntry<K, V>> = chainOrEntry
|
||||
for (index in 0..chain.size - 1) {
|
||||
for (index in chain.indices) {
|
||||
val entry = chain[index]
|
||||
if (equality.equals(key, entry.key)) {
|
||||
if (chain.size == 1) {
|
||||
|
||||
@@ -3948,7 +3948,7 @@ public fun <T> Array<out T>.takeLast(n: Int): List<T> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<T>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -3963,7 +3963,7 @@ public fun ByteArray.takeLast(n: Int): List<Byte> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Byte>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -3978,7 +3978,7 @@ public fun ShortArray.takeLast(n: Int): List<Short> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Short>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -3993,7 +3993,7 @@ public fun IntArray.takeLast(n: Int): List<Int> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Int>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4008,7 +4008,7 @@ public fun LongArray.takeLast(n: Int): List<Long> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Long>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4023,7 +4023,7 @@ public fun FloatArray.takeLast(n: Int): List<Float> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Float>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4038,7 +4038,7 @@ public fun DoubleArray.takeLast(n: Int): List<Double> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Double>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4053,7 +4053,7 @@ public fun BooleanArray.takeLast(n: Int): List<Boolean> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Boolean>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4068,7 +4068,7 @@ public fun CharArray.takeLast(n: Int): List<Char> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Char>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -11729,7 +11729,7 @@ public infix fun <R> CharArray.zip(other: Array<out R>): List<Pair<Char, R>> {
|
||||
public inline fun <T, R, V> Array<out T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11741,7 +11741,7 @@ public inline fun <T, R, V> Array<out T>.zip(other: Array<out R>, transform: (a:
|
||||
public inline fun <R, V> ByteArray.zip(other: Array<out R>, transform: (a: Byte, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11753,7 +11753,7 @@ public inline fun <R, V> ByteArray.zip(other: Array<out R>, transform: (a: Byte,
|
||||
public inline fun <R, V> ShortArray.zip(other: Array<out R>, transform: (a: Short, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11765,7 +11765,7 @@ public inline fun <R, V> ShortArray.zip(other: Array<out R>, transform: (a: Shor
|
||||
public inline fun <R, V> IntArray.zip(other: Array<out R>, transform: (a: Int, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11777,7 +11777,7 @@ public inline fun <R, V> IntArray.zip(other: Array<out R>, transform: (a: Int, b
|
||||
public inline fun <R, V> LongArray.zip(other: Array<out R>, transform: (a: Long, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11789,7 +11789,7 @@ public inline fun <R, V> LongArray.zip(other: Array<out R>, transform: (a: Long,
|
||||
public inline fun <R, V> FloatArray.zip(other: Array<out R>, transform: (a: Float, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11801,7 +11801,7 @@ public inline fun <R, V> FloatArray.zip(other: Array<out R>, transform: (a: Floa
|
||||
public inline fun <R, V> DoubleArray.zip(other: Array<out R>, transform: (a: Double, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11813,7 +11813,7 @@ public inline fun <R, V> DoubleArray.zip(other: Array<out R>, transform: (a: Dou
|
||||
public inline fun <R, V> BooleanArray.zip(other: Array<out R>, transform: (a: Boolean, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11825,7 +11825,7 @@ public inline fun <R, V> BooleanArray.zip(other: Array<out R>, transform: (a: Bo
|
||||
public inline fun <R, V> CharArray.zip(other: Array<out R>, transform: (a: Char, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12082,7 +12082,7 @@ public infix fun CharArray.zip(other: CharArray): List<Pair<Char, Char>> {
|
||||
public inline fun <V> ByteArray.zip(other: ByteArray, transform: (a: Byte, b: Byte) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12094,7 +12094,7 @@ public inline fun <V> ByteArray.zip(other: ByteArray, transform: (a: Byte, b: By
|
||||
public inline fun <V> ShortArray.zip(other: ShortArray, transform: (a: Short, b: Short) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12106,7 +12106,7 @@ public inline fun <V> ShortArray.zip(other: ShortArray, transform: (a: Short, b:
|
||||
public inline fun <V> IntArray.zip(other: IntArray, transform: (a: Int, b: Int) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12118,7 +12118,7 @@ public inline fun <V> IntArray.zip(other: IntArray, transform: (a: Int, b: Int)
|
||||
public inline fun <V> LongArray.zip(other: LongArray, transform: (a: Long, b: Long) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12130,7 +12130,7 @@ public inline fun <V> LongArray.zip(other: LongArray, transform: (a: Long, b: Lo
|
||||
public inline fun <V> FloatArray.zip(other: FloatArray, transform: (a: Float, b: Float) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12142,7 +12142,7 @@ public inline fun <V> FloatArray.zip(other: FloatArray, transform: (a: Float, b:
|
||||
public inline fun <V> DoubleArray.zip(other: DoubleArray, transform: (a: Double, b: Double) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12154,7 +12154,7 @@ public inline fun <V> DoubleArray.zip(other: DoubleArray, transform: (a: Double,
|
||||
public inline fun <V> BooleanArray.zip(other: BooleanArray, transform: (a: Boolean, b: Boolean) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12166,7 +12166,7 @@ public inline fun <V> BooleanArray.zip(other: BooleanArray, transform: (a: Boole
|
||||
public inline fun <V> CharArray.zip(other: CharArray, transform: (a: Char, b: Char) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
|
||||
@@ -551,7 +551,7 @@ public fun <T> Iterable<T>.drop(n: Int): List<T> {
|
||||
list = ArrayList<T>(resultSize)
|
||||
if (this is List<T>) {
|
||||
if (this is RandomAccess) {
|
||||
for (index in n..size - 1)
|
||||
for (index in n until size)
|
||||
list.add(this[index])
|
||||
} else {
|
||||
for (item in listIterator(n))
|
||||
@@ -742,7 +742,7 @@ public fun <T> List<T>.takeLast(n: Int): List<T> {
|
||||
if (n == 1) return listOf(last())
|
||||
val list = ArrayList<T>(n)
|
||||
if (this is RandomAccess) {
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
} else {
|
||||
for (item in listIterator(size - n))
|
||||
|
||||
@@ -253,7 +253,7 @@ public fun String.dropLast(n: Int): String {
|
||||
* Returns a subsequence of this char sequence containing all characters except last characters that satisfy the given [predicate].
|
||||
*/
|
||||
public inline fun CharSequence.dropLastWhile(predicate: (Char) -> Boolean): CharSequence {
|
||||
for (index in this.indices.reversed())
|
||||
for (index in lastIndex downTo 0)
|
||||
if (!predicate(this[index]))
|
||||
return subSequence(0, index + 1)
|
||||
return ""
|
||||
@@ -263,7 +263,7 @@ public inline fun CharSequence.dropLastWhile(predicate: (Char) -> Boolean): Char
|
||||
* Returns a string containing all characters except last characters that satisfy the given [predicate].
|
||||
*/
|
||||
public inline fun String.dropLastWhile(predicate: (Char) -> Boolean): String {
|
||||
for (index in this.indices.reversed())
|
||||
for (index in lastIndex downTo 0)
|
||||
if (!predicate(this[index]))
|
||||
return substring(0, index + 1)
|
||||
return ""
|
||||
@@ -359,7 +359,7 @@ public inline fun <C : Appendable> CharSequence.filterNotTo(destination: C, pred
|
||||
* Appends all characters matching the given [predicate] to the given [destination].
|
||||
*/
|
||||
public inline fun <C : Appendable> CharSequence.filterTo(destination: C, predicate: (Char) -> Boolean): C {
|
||||
for (index in 0..length - 1) {
|
||||
for (index in 0 until length) {
|
||||
val element = get(index)
|
||||
if (predicate(element)) destination.append(element)
|
||||
}
|
||||
@@ -465,7 +465,7 @@ public inline fun String.takeLastWhile(predicate: (Char) -> Boolean): String {
|
||||
* Returns a subsequence of this char sequence containing the first characters that satisfy the given [predicate].
|
||||
*/
|
||||
public inline fun CharSequence.takeWhile(predicate: (Char) -> Boolean): CharSequence {
|
||||
for (index in 0..length - 1)
|
||||
for (index in 0 until length)
|
||||
if (!predicate(get(index))) {
|
||||
return subSequence(0, index)
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public inline fun CharSequence.takeWhile(predicate: (Char) -> Boolean): CharSequ
|
||||
* Returns a string containing the first characters that satisfy the given [predicate].
|
||||
*/
|
||||
public inline fun String.takeWhile(predicate: (Char) -> Boolean): String {
|
||||
for (index in 0..length - 1)
|
||||
for (index in 0 until length)
|
||||
if (!predicate(get(index))) {
|
||||
return substring(0, index)
|
||||
}
|
||||
@@ -1313,7 +1313,7 @@ public infix fun CharSequence.zip(other: CharSequence): List<Pair<Char, Char>> {
|
||||
public inline fun <V> CharSequence.zip(other: CharSequence, transform: (a: Char, b: Char) -> V): List<V> {
|
||||
val length = minOf(this.length, other.length)
|
||||
val list = ArrayList<V>(length)
|
||||
for (i in 0..length-1) {
|
||||
for (i in 0 until length) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -1344,7 +1344,7 @@ public inline fun <R> CharSequence.zipWithNext(transform: (a: Char, b: Char) ->
|
||||
val size = length - 1
|
||||
if (size < 1) return emptyList()
|
||||
val result = ArrayList<R>(size)
|
||||
for (index in 0..size - 1) {
|
||||
for (index in 0 until size) {
|
||||
result.add(transform(this[index], this[index + 1]))
|
||||
}
|
||||
return result
|
||||
|
||||
@@ -3946,7 +3946,7 @@ public fun <T> Array<out T>.takeLast(n: Int): List<T> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<T>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -3961,7 +3961,7 @@ public fun ByteArray.takeLast(n: Int): List<Byte> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Byte>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -3976,7 +3976,7 @@ public fun ShortArray.takeLast(n: Int): List<Short> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Short>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -3991,7 +3991,7 @@ public fun IntArray.takeLast(n: Int): List<Int> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Int>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4006,7 +4006,7 @@ public fun LongArray.takeLast(n: Int): List<Long> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Long>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4021,7 +4021,7 @@ public fun FloatArray.takeLast(n: Int): List<Float> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Float>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4036,7 +4036,7 @@ public fun DoubleArray.takeLast(n: Int): List<Double> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Double>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4051,7 +4051,7 @@ public fun BooleanArray.takeLast(n: Int): List<Boolean> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Boolean>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -4066,7 +4066,7 @@ public fun CharArray.takeLast(n: Int): List<Char> {
|
||||
if (n >= size) return toList()
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
val list = ArrayList<Char>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
}
|
||||
@@ -11799,7 +11799,7 @@ public infix fun <R> CharArray.zip(other: Array<out R>): List<Pair<Char, R>> {
|
||||
public inline fun <T, R, V> Array<out T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11811,7 +11811,7 @@ public inline fun <T, R, V> Array<out T>.zip(other: Array<out R>, transform: (a:
|
||||
public inline fun <R, V> ByteArray.zip(other: Array<out R>, transform: (a: Byte, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11823,7 +11823,7 @@ public inline fun <R, V> ByteArray.zip(other: Array<out R>, transform: (a: Byte,
|
||||
public inline fun <R, V> ShortArray.zip(other: Array<out R>, transform: (a: Short, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11835,7 +11835,7 @@ public inline fun <R, V> ShortArray.zip(other: Array<out R>, transform: (a: Shor
|
||||
public inline fun <R, V> IntArray.zip(other: Array<out R>, transform: (a: Int, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11847,7 +11847,7 @@ public inline fun <R, V> IntArray.zip(other: Array<out R>, transform: (a: Int, b
|
||||
public inline fun <R, V> LongArray.zip(other: Array<out R>, transform: (a: Long, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11859,7 +11859,7 @@ public inline fun <R, V> LongArray.zip(other: Array<out R>, transform: (a: Long,
|
||||
public inline fun <R, V> FloatArray.zip(other: Array<out R>, transform: (a: Float, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11871,7 +11871,7 @@ public inline fun <R, V> FloatArray.zip(other: Array<out R>, transform: (a: Floa
|
||||
public inline fun <R, V> DoubleArray.zip(other: Array<out R>, transform: (a: Double, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11883,7 +11883,7 @@ public inline fun <R, V> DoubleArray.zip(other: Array<out R>, transform: (a: Dou
|
||||
public inline fun <R, V> BooleanArray.zip(other: Array<out R>, transform: (a: Boolean, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -11895,7 +11895,7 @@ public inline fun <R, V> BooleanArray.zip(other: Array<out R>, transform: (a: Bo
|
||||
public inline fun <R, V> CharArray.zip(other: Array<out R>, transform: (a: Char, b: R) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12152,7 +12152,7 @@ public infix fun CharArray.zip(other: CharArray): List<Pair<Char, Char>> {
|
||||
public inline fun <V> ByteArray.zip(other: ByteArray, transform: (a: Byte, b: Byte) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12164,7 +12164,7 @@ public inline fun <V> ByteArray.zip(other: ByteArray, transform: (a: Byte, b: By
|
||||
public inline fun <V> ShortArray.zip(other: ShortArray, transform: (a: Short, b: Short) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12176,7 +12176,7 @@ public inline fun <V> ShortArray.zip(other: ShortArray, transform: (a: Short, b:
|
||||
public inline fun <V> IntArray.zip(other: IntArray, transform: (a: Int, b: Int) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12188,7 +12188,7 @@ public inline fun <V> IntArray.zip(other: IntArray, transform: (a: Int, b: Int)
|
||||
public inline fun <V> LongArray.zip(other: LongArray, transform: (a: Long, b: Long) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12200,7 +12200,7 @@ public inline fun <V> LongArray.zip(other: LongArray, transform: (a: Long, b: Lo
|
||||
public inline fun <V> FloatArray.zip(other: FloatArray, transform: (a: Float, b: Float) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12212,7 +12212,7 @@ public inline fun <V> FloatArray.zip(other: FloatArray, transform: (a: Float, b:
|
||||
public inline fun <V> DoubleArray.zip(other: DoubleArray, transform: (a: Double, b: Double) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12224,7 +12224,7 @@ public inline fun <V> DoubleArray.zip(other: DoubleArray, transform: (a: Double,
|
||||
public inline fun <V> BooleanArray.zip(other: BooleanArray, transform: (a: Boolean, b: Boolean) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -12236,7 +12236,7 @@ public inline fun <V> BooleanArray.zip(other: BooleanArray, transform: (a: Boole
|
||||
public inline fun <V> CharArray.zip(other: CharArray, transform: (a: Char, b: Char) -> V): List<V> {
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
|
||||
@@ -551,7 +551,7 @@ public fun <T> Iterable<T>.drop(n: Int): List<T> {
|
||||
list = ArrayList<T>(resultSize)
|
||||
if (this is List<T>) {
|
||||
if (this is RandomAccess) {
|
||||
for (index in n..size - 1)
|
||||
for (index in n until size)
|
||||
list.add(this[index])
|
||||
} else {
|
||||
for (item in listIterator(n))
|
||||
@@ -742,7 +742,7 @@ public fun <T> List<T>.takeLast(n: Int): List<T> {
|
||||
if (n == 1) return listOf(last())
|
||||
val list = ArrayList<T>(n)
|
||||
if (this is RandomAccess) {
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
} else {
|
||||
for (item in listIterator(size - n))
|
||||
|
||||
@@ -253,7 +253,7 @@ public fun String.dropLast(n: Int): String {
|
||||
* Returns a subsequence of this char sequence containing all characters except last characters that satisfy the given [predicate].
|
||||
*/
|
||||
public inline fun CharSequence.dropLastWhile(predicate: (Char) -> Boolean): CharSequence {
|
||||
for (index in this.indices.reversed())
|
||||
for (index in lastIndex downTo 0)
|
||||
if (!predicate(this[index]))
|
||||
return subSequence(0, index + 1)
|
||||
return ""
|
||||
@@ -263,7 +263,7 @@ public inline fun CharSequence.dropLastWhile(predicate: (Char) -> Boolean): Char
|
||||
* Returns a string containing all characters except last characters that satisfy the given [predicate].
|
||||
*/
|
||||
public inline fun String.dropLastWhile(predicate: (Char) -> Boolean): String {
|
||||
for (index in this.indices.reversed())
|
||||
for (index in lastIndex downTo 0)
|
||||
if (!predicate(this[index]))
|
||||
return substring(0, index + 1)
|
||||
return ""
|
||||
@@ -359,7 +359,7 @@ public inline fun <C : Appendable> CharSequence.filterNotTo(destination: C, pred
|
||||
* Appends all characters matching the given [predicate] to the given [destination].
|
||||
*/
|
||||
public inline fun <C : Appendable> CharSequence.filterTo(destination: C, predicate: (Char) -> Boolean): C {
|
||||
for (index in 0..length - 1) {
|
||||
for (index in 0 until length) {
|
||||
val element = get(index)
|
||||
if (predicate(element)) destination.append(element)
|
||||
}
|
||||
@@ -465,7 +465,7 @@ public inline fun String.takeLastWhile(predicate: (Char) -> Boolean): String {
|
||||
* Returns a subsequence of this char sequence containing the first characters that satisfy the given [predicate].
|
||||
*/
|
||||
public inline fun CharSequence.takeWhile(predicate: (Char) -> Boolean): CharSequence {
|
||||
for (index in 0..length - 1)
|
||||
for (index in 0 until length)
|
||||
if (!predicate(get(index))) {
|
||||
return subSequence(0, index)
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public inline fun CharSequence.takeWhile(predicate: (Char) -> Boolean): CharSequ
|
||||
* Returns a string containing the first characters that satisfy the given [predicate].
|
||||
*/
|
||||
public inline fun String.takeWhile(predicate: (Char) -> Boolean): String {
|
||||
for (index in 0..length - 1)
|
||||
for (index in 0 until length)
|
||||
if (!predicate(get(index))) {
|
||||
return substring(0, index)
|
||||
}
|
||||
@@ -1321,7 +1321,7 @@ public infix fun CharSequence.zip(other: CharSequence): List<Pair<Char, Char>> {
|
||||
public inline fun <V> CharSequence.zip(other: CharSequence, transform: (a: Char, b: Char) -> V): List<V> {
|
||||
val length = minOf(this.length, other.length)
|
||||
val list = ArrayList<V>(length)
|
||||
for (i in 0..length-1) {
|
||||
for (i in 0 until length) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -1352,7 +1352,7 @@ public inline fun <R> CharSequence.zipWithNext(transform: (a: Char, b: Char) ->
|
||||
val size = length - 1
|
||||
if (size < 1) return emptyList()
|
||||
val result = ArrayList<R>(size)
|
||||
for (index in 0..size - 1) {
|
||||
for (index in 0 until size) {
|
||||
result.add(transform(this[index], this[index + 1]))
|
||||
}
|
||||
return result
|
||||
|
||||
@@ -203,7 +203,7 @@ private class RingBuffer<T>(val capacity: Int): AbstractList<T>(), RandomAccess
|
||||
|
||||
// TODO: replace with Array.fill from stdlib when available in common
|
||||
private fun <T> Array<T>.fill(element: T, fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
for (idx in fromIndex .. toIndex-1) {
|
||||
for (idx in fromIndex until toIndex) {
|
||||
this[idx] = element
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ internal fun CharSequence.regionMatchesImpl(thisOffset: Int, other: CharSequence
|
||||
return false
|
||||
}
|
||||
|
||||
for (index in 0..length-1) {
|
||||
for (index in 0 until length) {
|
||||
if (!this[thisOffset + index].equals(other[otherOffset + index], ignoreCase))
|
||||
return false
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ private class DelimitedRangesSequence(private val input: CharSequence, private v
|
||||
}
|
||||
else {
|
||||
val (index,length) = match
|
||||
nextItem = currentStartIndex..index-1
|
||||
nextItem = currentStartIndex until index
|
||||
currentStartIndex = index + length
|
||||
nextSearchIndex = currentStartIndex + if (length == 0) 1 else 0
|
||||
}
|
||||
|
||||
@@ -281,5 +281,5 @@ private class MatcherMatchResult(private val matcher: Matcher, private val input
|
||||
}
|
||||
|
||||
|
||||
private fun java.util.regex.MatchResult.range(): IntRange = start()..end()-1
|
||||
private fun java.util.regex.MatchResult.range(groupIndex: Int): IntRange = start(groupIndex)..end(groupIndex)-1
|
||||
private fun java.util.regex.MatchResult.range(): IntRange = start() until end()
|
||||
private fun java.util.regex.MatchResult.range(groupIndex: Int): IntRange = start(groupIndex) until end(groupIndex)
|
||||
|
||||
@@ -128,7 +128,7 @@ public inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? {
|
||||
public inline fun repeat(times: Int, action: (Int) -> Unit) {
|
||||
contract { callsInPlace(action) }
|
||||
|
||||
for (index in 0..times - 1) {
|
||||
for (index in 0 until times) {
|
||||
action(index)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ object Filtering : TemplateGroupBase() {
|
||||
list = ArrayList<T>(resultSize)
|
||||
if (this is List<T>) {
|
||||
if (this is RandomAccess) {
|
||||
for (index in n..size - 1)
|
||||
for (index in n until size)
|
||||
list.add(this[index])
|
||||
} else {
|
||||
for (item in listIterator(n))
|
||||
@@ -256,7 +256,7 @@ object Filtering : TemplateGroupBase() {
|
||||
if (n == 1) return listOf(this[size - 1])
|
||||
|
||||
val list = ArrayList<T>(n)
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
return list
|
||||
"""
|
||||
@@ -271,7 +271,7 @@ object Filtering : TemplateGroupBase() {
|
||||
|
||||
val list = ArrayList<T>(n)
|
||||
if (this is RandomAccess) {
|
||||
for (index in size - n .. size - 1)
|
||||
for (index in size - n until size)
|
||||
list.add(this[index])
|
||||
} else {
|
||||
for (item in listIterator(size - n))
|
||||
@@ -364,7 +364,7 @@ object Filtering : TemplateGroupBase() {
|
||||
}
|
||||
body(Strings, CharSequences) {
|
||||
"""
|
||||
for (index in 0..length - 1)
|
||||
for (index in 0 until length)
|
||||
if (!predicate(get(index))) {
|
||||
return ${subsequence(f, "0", "index")}
|
||||
}
|
||||
@@ -422,7 +422,7 @@ object Filtering : TemplateGroupBase() {
|
||||
}
|
||||
body(CharSequences, Strings) {
|
||||
"""
|
||||
for (index in this.indices.reversed())
|
||||
for (index in lastIndex downTo 0)
|
||||
if (!predicate(this[index]))
|
||||
return ${subsequence(f, "0", "index + 1")}
|
||||
|
||||
@@ -537,7 +537,7 @@ object Filtering : TemplateGroupBase() {
|
||||
|
||||
body(CharSequences) {
|
||||
"""
|
||||
for (index in 0..length - 1) {
|
||||
for (index in 0 until length) {
|
||||
val element = get(index)
|
||||
if (predicate(element)) destination.append(element)
|
||||
}
|
||||
|
||||
@@ -951,7 +951,7 @@ object Generators : TemplateGroupBase() {
|
||||
val size = ${if (f == CharSequences) "length" else "size" } - 1
|
||||
if (size < 1) return emptyList()
|
||||
val result = ArrayList<R>(size)
|
||||
for (index in 0..size - 1) {
|
||||
for (index in 0 until size) {
|
||||
result.add(transform(this[index], this[index + 1]))
|
||||
}
|
||||
return result
|
||||
@@ -1064,7 +1064,7 @@ object Generators : TemplateGroupBase() {
|
||||
"""
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -1088,7 +1088,7 @@ object Generators : TemplateGroupBase() {
|
||||
"""
|
||||
val size = minOf(size, other.size)
|
||||
val list = ArrayList<V>(size)
|
||||
for (i in 0..size-1) {
|
||||
for (i in 0 until size) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
@@ -1131,7 +1131,7 @@ object Generators : TemplateGroupBase() {
|
||||
val length = minOf(this.length, other.length)
|
||||
|
||||
val list = ArrayList<V>(length)
|
||||
for (i in 0..length-1) {
|
||||
for (i in 0 until length) {
|
||||
list.add(transform(this[i], other[i]))
|
||||
}
|
||||
return list
|
||||
|
||||
Reference in New Issue
Block a user