Array.copyOfRange: rename from, to to fromIndex, toIndex

This commit is contained in:
Ilya Gorbunov
2015-07-23 00:20:47 +03:00
parent aeb7666578
commit 877cb72ba1
4 changed files with 42 additions and 42 deletions
+18 -18
View File
@@ -214,72 +214,72 @@ public fun <T> Array<out T>.copyOf(newSize: Int): Array<T?> {
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
suppress("NOTHING_TO_INLINE") suppress("NOTHING_TO_INLINE")
public inline fun <T> Array<out T>.copyOfRange(from: Int, to: Int): Array<T> { public inline fun <T> Array<out T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T> {
return (this: dynamic).slice(from, to) return (this: dynamic).slice(fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
suppress("NOTHING_TO_INLINE") suppress("NOTHING_TO_INLINE")
public inline fun BooleanArray.copyOfRange(from: Int, to: Int): BooleanArray { public inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray {
return (this: dynamic).slice(from, to) return (this: dynamic).slice(fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
suppress("NOTHING_TO_INLINE") suppress("NOTHING_TO_INLINE")
public inline fun ByteArray.copyOfRange(from: Int, to: Int): ByteArray { public inline fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray {
return (this: dynamic).slice(from, to) return (this: dynamic).slice(fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
suppress("NOTHING_TO_INLINE") suppress("NOTHING_TO_INLINE")
public inline fun CharArray.copyOfRange(from: Int, to: Int): CharArray { public inline fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray {
return (this: dynamic).slice(from, to) return (this: dynamic).slice(fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
suppress("NOTHING_TO_INLINE") suppress("NOTHING_TO_INLINE")
public inline fun DoubleArray.copyOfRange(from: Int, to: Int): DoubleArray { public inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray {
return (this: dynamic).slice(from, to) return (this: dynamic).slice(fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
suppress("NOTHING_TO_INLINE") suppress("NOTHING_TO_INLINE")
public inline fun FloatArray.copyOfRange(from: Int, to: Int): FloatArray { public inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray {
return (this: dynamic).slice(from, to) return (this: dynamic).slice(fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
suppress("NOTHING_TO_INLINE") suppress("NOTHING_TO_INLINE")
public inline fun IntArray.copyOfRange(from: Int, to: Int): IntArray { public inline fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray {
return (this: dynamic).slice(from, to) return (this: dynamic).slice(fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
suppress("NOTHING_TO_INLINE") suppress("NOTHING_TO_INLINE")
public inline fun LongArray.copyOfRange(from: Int, to: Int): LongArray { public inline fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray {
return (this: dynamic).slice(from, to) return (this: dynamic).slice(fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
suppress("NOTHING_TO_INLINE") suppress("NOTHING_TO_INLINE")
public inline fun ShortArray.copyOfRange(from: Int, to: Int): ShortArray { public inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray {
return (this: dynamic).slice(from, to) return (this: dynamic).slice(fromIndex, toIndex)
} }
/** /**
+20 -20
View File
@@ -345,72 +345,72 @@ public fun <T> Array<T>.copyOf(newSize: Int): Array<T?> {
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
public fun <T> Array<out T>.copyOfRange(from: Int, to: Int): Array<out T> { public fun <T> Array<out T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<out T> {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
public fun BooleanArray.copyOfRange(from: Int, to: Int): BooleanArray { public fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
public fun ByteArray.copyOfRange(from: Int, to: Int): ByteArray { public fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
public fun CharArray.copyOfRange(from: Int, to: Int): CharArray { public fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
public fun DoubleArray.copyOfRange(from: Int, to: Int): DoubleArray { public fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
public fun FloatArray.copyOfRange(from: Int, to: Int): FloatArray { public fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
public fun IntArray.copyOfRange(from: Int, to: Int): IntArray { public fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
public fun LongArray.copyOfRange(from: Int, to: Int): LongArray { public fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
public fun ShortArray.copyOfRange(from: Int, to: Int): ShortArray { public fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
* Returns new array which is a copy of range of original array. * Returns new array which is a copy of range of original array.
*/ */
platformName("mutableCopyOfRange") platformName("mutableCopyOfRange")
public fun <T> Array<T>.copyOfRange(from: Int, to: Int): Array<T> { public fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T> {
return Arrays.copyOfRange(this, from, to) return Arrays.copyOfRange(this, fromIndex, toIndex)
} }
/** /**
@@ -37,7 +37,7 @@ fun specialJS(): List<GenericFunction> {
} }
} }
templates add f("copyOfRange(from: Int, to: Int)") { templates add f("copyOfRange(fromIndex: Int, toIndex: Int)") {
// TODO: Arguments checking as in java? // TODO: Arguments checking as in java?
only(ArraysOfObjects, ArraysOfPrimitives) only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns new array which is a copy of range of original array." } doc { "Returns new array which is a copy of range of original array." }
@@ -46,7 +46,7 @@ fun specialJS(): List<GenericFunction> {
returns("SELF") returns("SELF")
returns(ArraysOfObjects) { "Array<T>" } returns(ArraysOfObjects) { "Array<T>" }
body { body {
"return (this: dynamic).slice(from, to)" "return (this: dynamic).slice(fromIndex, toIndex)"
} }
} }
@@ -50,13 +50,13 @@ fun specialJVM(): List<GenericFunction> {
} }
templates add f("copyOfRange(from: Int, to: Int)") { templates add f("copyOfRange(fromIndex: Int, toIndex: Int)") {
only(ArraysOfObjects, InvariantArraysOfObjects, ArraysOfPrimitives) only(ArraysOfObjects, InvariantArraysOfObjects, ArraysOfPrimitives)
doc { "Returns new array which is a copy of range of original array." } doc { "Returns new array which is a copy of range of original array." }
returns("SELF") returns("SELF")
annotations(InvariantArraysOfObjects) { """platformName("mutableCopyOfRange")"""} annotations(InvariantArraysOfObjects) { """platformName("mutableCopyOfRange")"""}
body { body {
"return Arrays.copyOfRange(this, from, to)" "return Arrays.copyOfRange(this, fromIndex, toIndex)"
} }
} }