StdLib cleanup, deprecated symbol usage: replace end with endInclusive

This commit is contained in:
Ilya Gorbunov
2015-11-14 06:01:15 +03:00
parent 07654eb82b
commit 838109c302
6 changed files with 32 additions and 32 deletions
+18 -18
View File
@@ -3428,7 +3428,7 @@ public inline fun <C : MutableCollection<in Short>> ShortArray.filterTo(destinat
*/
public fun <T> Array<out T>.slice(indices: IntRange): List<T> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
@@ -3436,7 +3436,7 @@ public fun <T> Array<out T>.slice(indices: IntRange): List<T> {
*/
public fun BooleanArray.slice(indices: IntRange): List<Boolean> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
@@ -3444,7 +3444,7 @@ public fun BooleanArray.slice(indices: IntRange): List<Boolean> {
*/
public fun ByteArray.slice(indices: IntRange): List<Byte> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
@@ -3452,7 +3452,7 @@ public fun ByteArray.slice(indices: IntRange): List<Byte> {
*/
public fun CharArray.slice(indices: IntRange): List<Char> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
@@ -3460,7 +3460,7 @@ public fun CharArray.slice(indices: IntRange): List<Char> {
*/
public fun DoubleArray.slice(indices: IntRange): List<Double> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
@@ -3468,7 +3468,7 @@ public fun DoubleArray.slice(indices: IntRange): List<Double> {
*/
public fun FloatArray.slice(indices: IntRange): List<Float> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
@@ -3476,7 +3476,7 @@ public fun FloatArray.slice(indices: IntRange): List<Float> {
*/
public fun IntArray.slice(indices: IntRange): List<Int> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
@@ -3484,7 +3484,7 @@ public fun IntArray.slice(indices: IntRange): List<Int> {
*/
public fun LongArray.slice(indices: IntRange): List<Long> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
@@ -3492,7 +3492,7 @@ public fun LongArray.slice(indices: IntRange): List<Long> {
*/
public fun ShortArray.slice(indices: IntRange): List<Short> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
@@ -3725,7 +3725,7 @@ public fun ShortArray.sliceArray(indices: Collection<Int>): ShortArray {
*/
public fun <T> Array<out T>.sliceArray(indices: IntRange): Array<out T> {
if (indices.isEmpty()) return copyOfRange(0, 0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
}
/**
@@ -3733,7 +3733,7 @@ public fun <T> Array<out T>.sliceArray(indices: IntRange): Array<out T> {
*/
public fun BooleanArray.sliceArray(indices: IntRange): BooleanArray {
if (indices.isEmpty()) return BooleanArray(0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
}
/**
@@ -3741,7 +3741,7 @@ public fun BooleanArray.sliceArray(indices: IntRange): BooleanArray {
*/
public fun ByteArray.sliceArray(indices: IntRange): ByteArray {
if (indices.isEmpty()) return ByteArray(0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
}
/**
@@ -3749,7 +3749,7 @@ public fun ByteArray.sliceArray(indices: IntRange): ByteArray {
*/
public fun CharArray.sliceArray(indices: IntRange): CharArray {
if (indices.isEmpty()) return CharArray(0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
}
/**
@@ -3757,7 +3757,7 @@ public fun CharArray.sliceArray(indices: IntRange): CharArray {
*/
public fun DoubleArray.sliceArray(indices: IntRange): DoubleArray {
if (indices.isEmpty()) return DoubleArray(0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
}
/**
@@ -3765,7 +3765,7 @@ public fun DoubleArray.sliceArray(indices: IntRange): DoubleArray {
*/
public fun FloatArray.sliceArray(indices: IntRange): FloatArray {
if (indices.isEmpty()) return FloatArray(0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
}
/**
@@ -3773,7 +3773,7 @@ public fun FloatArray.sliceArray(indices: IntRange): FloatArray {
*/
public fun IntArray.sliceArray(indices: IntRange): IntArray {
if (indices.isEmpty()) return IntArray(0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
}
/**
@@ -3781,7 +3781,7 @@ public fun IntArray.sliceArray(indices: IntRange): IntArray {
*/
public fun LongArray.sliceArray(indices: IntRange): LongArray {
if (indices.isEmpty()) return LongArray(0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
}
/**
@@ -3789,7 +3789,7 @@ public fun LongArray.sliceArray(indices: IntRange): LongArray {
*/
public fun ShortArray.sliceArray(indices: IntRange): ShortArray {
if (indices.isEmpty()) return ShortArray(0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
}
/**
@@ -734,7 +734,7 @@ public inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(destinat
*/
public fun <T> List<T>.slice(indices: IntRange): List<T> {
if (indices.isEmpty()) return listOf()
return this.subList(indices.start, indices.end + 1).toList()
return this.subList(indices.start, indices.endInclusive + 1).toList()
}
/**
+7 -7
View File
@@ -279,12 +279,12 @@ public fun CharSequence.hasSurrogatePairAt(index: Int): Boolean {
/**
* Returns a substring specified by the given [range].
*/
public fun String.substring(range: IntRange): String = substring(range.start, range.end + 1)
public fun String.substring(range: IntRange): String = substring(range.start, range.endInclusive + 1)
/**
* Returns a subsequence of this char sequence specified by the given [range].
*/
public fun CharSequence.subSequence(range: IntRange): CharSequence = subSequence(range.start, range.end + 1)
public fun CharSequence.subSequence(range: IntRange): CharSequence = subSequence(range.start, range.endInclusive + 1)
/**
* Returns a substring of chars from a range of this char sequence specified by [start] and [end] indices.
@@ -294,7 +294,7 @@ public fun CharSequence.substring(start: Int, end: Int = length): String = subSe
/**
* Returns a substring of chars from a [range] of this char sequence.
*/
public fun CharSequence.substring(range: IntRange): String = subSequence(range.start, range.end + 1).toString()
public fun CharSequence.substring(range: IntRange): String = subSequence(range.start, range.endInclusive + 1).toString()
/**
* Returns a substring before the first occurrence of [delimiter].
@@ -399,7 +399,7 @@ public fun String.replaceRange(firstIndex: Int, lastIndex: Int, replacement: Cha
* The end index of the [range] is included in the part to be replaced.
*/
public fun CharSequence.replaceRange(range: IntRange, replacement: CharSequence): CharSequence
= replaceRange(range.start, range.end + 1, replacement)
= replaceRange(range.start, range.endInclusive + 1, replacement)
/**
* Replace the part of string at the given [range] with the [replacement] string.
@@ -407,7 +407,7 @@ public fun CharSequence.replaceRange(range: IntRange, replacement: CharSequence)
* The end index of the [range] is included in the part to be replaced.
*/
public fun String.replaceRange(range: IntRange, replacement: CharSequence): String
= replaceRange(range.start, range.end + 1, replacement)
= replaceRange(range.start, range.endInclusive + 1, replacement)
/**
* Returns a char sequence with content of this char sequence where its part at the given range is removed.
@@ -445,14 +445,14 @@ public fun String.removeRange(firstIndex: Int, lastIndex: Int): String
*
* The end index of the [range] is included in the removed part.
*/
public fun CharSequence.removeRange(range: IntRange): CharSequence = removeRange(range.start, range.end + 1)
public fun CharSequence.removeRange(range: IntRange): CharSequence = removeRange(range.start, range.endInclusive + 1)
/**
* Removes the part of a string at the given [range].
*
* The end index of the [range] is included in the removed part.
*/
public fun String.removeRange(range: IntRange): String = removeRange(range.start, range.end + 1)
public fun String.removeRange(range: IntRange): String = removeRange(range.start, range.endInclusive + 1)
/**
* If this char sequence starts with the given [prefix], returns a new char sequence
@@ -168,7 +168,7 @@ public class Regex internal constructor(private val nativePattern: Pattern) {
val foundMatch = match!!
sb.append(input, lastStart, foundMatch.range.start)
sb.append(transform(foundMatch))
lastStart = foundMatch.range.end + 1
lastStart = foundMatch.range.endInclusive + 1
match = foundMatch.next()
} while (lastStart < length && match != null)
@@ -462,7 +462,7 @@ class CollectionTest {
val data = listOf("foo", "bar")
val indices = data.indices
assertEquals(0, indices.start)
assertEquals(1, indices.end)
assertEquals(1, indices.endInclusive)
assertEquals(0..data.size - 1, indices)
}
@@ -567,13 +567,13 @@ fun filtering(): List<GenericFunction> {
body(Lists) {
"""
if (indices.isEmpty()) return listOf()
return this.subList(indices.start, indices.end + 1).toList()
return this.subList(indices.start, indices.endInclusive + 1).toList()
"""
}
body(ArraysOfPrimitives, ArraysOfObjects) {
"""
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.end + 1).asList()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
"""
}
@@ -620,13 +620,13 @@ fun filtering(): List<GenericFunction> {
body(ArraysOfObjects) {
"""
if (indices.isEmpty()) return copyOfRange(0, 0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
"""
}
body(ArraysOfPrimitives) {
"""
if (indices.isEmpty()) return SELF(0)
return copyOfRange(indices.start, indices.end + 1)
return copyOfRange(indices.start, indices.endInclusive + 1)
"""
}
}