Allow to specify optional from and to indices for filling an array.

#KT-8382 Fixed
This commit is contained in:
Ilya Gorbunov
2015-07-21 02:28:19 +03:00
parent c1975d0b2e
commit 46858ddabd
2 changed files with 20 additions and 20 deletions
+18 -18
View File
@@ -409,64 +409,64 @@ public fun <T> Array<T>.copyOfRange(from: Int, to: Int): Array<T> {
/**
* Fills original array with the provided value.
*/
public fun BooleanArray.fill(element: Boolean): Unit {
Arrays.fill(this, element)
public fun BooleanArray.fill(element: Boolean, fromIndex: Int = 0, toIndex: Int = size()): Unit {
Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Fills original array with the provided value.
*/
public fun ByteArray.fill(element: Byte): Unit {
Arrays.fill(this, element)
public fun ByteArray.fill(element: Byte, fromIndex: Int = 0, toIndex: Int = size()): Unit {
Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Fills original array with the provided value.
*/
public fun CharArray.fill(element: Char): Unit {
Arrays.fill(this, element)
public fun CharArray.fill(element: Char, fromIndex: Int = 0, toIndex: Int = size()): Unit {
Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Fills original array with the provided value.
*/
public fun DoubleArray.fill(element: Double): Unit {
Arrays.fill(this, element)
public fun DoubleArray.fill(element: Double, fromIndex: Int = 0, toIndex: Int = size()): Unit {
Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Fills original array with the provided value.
*/
public fun FloatArray.fill(element: Float): Unit {
Arrays.fill(this, element)
public fun FloatArray.fill(element: Float, fromIndex: Int = 0, toIndex: Int = size()): Unit {
Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Fills original array with the provided value.
*/
public fun IntArray.fill(element: Int): Unit {
Arrays.fill(this, element)
public fun IntArray.fill(element: Int, fromIndex: Int = 0, toIndex: Int = size()): Unit {
Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Fills original array with the provided value.
*/
public fun LongArray.fill(element: Long): Unit {
Arrays.fill(this, element)
public fun LongArray.fill(element: Long, fromIndex: Int = 0, toIndex: Int = size()): Unit {
Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Fills original array with the provided value.
*/
public fun ShortArray.fill(element: Short): Unit {
Arrays.fill(this, element)
public fun ShortArray.fill(element: Short, fromIndex: Int = 0, toIndex: Int = size()): Unit {
Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Fills original array with the provided value.
*/
public fun <T> Array<T>.fill(element: T): Unit {
Arrays.fill(this, element)
public fun <T> Array<T>.fill(element: T, fromIndex: Int = 0, toIndex: Int = size()): Unit {
Arrays.fill(this, fromIndex, toIndex, element)
}
/**