Common Array.fill for unsigned arrays, improve docs, native impl name
KT-32359
This commit is contained in:
@@ -6339,48 +6339,111 @@ public expect fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): Boolea
|
||||
public expect fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun <T> Array<T>.fill(element: T, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun ByteArray.fill(element: Byte, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun ShortArray.fill(element: Short, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun IntArray.fill(element: Int, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun LongArray.fill(element: Long, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun FloatArray.fill(element: Float, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun DoubleArray.fill(element: Double, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun BooleanArray.fill(element: Boolean, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public expect fun CharArray.fill(element: Char, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
|
||||
@@ -3231,32 +3231,64 @@ public inline fun UShortArray.copyOfRange(fromIndex: Int, toIndex: Int): UShortA
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
public expect fun UIntArray.fill(element: UInt, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
public fun UIntArray.fill(element: UInt, fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
storage.fill(element.toInt(), fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
public expect fun ULongArray.fill(element: ULong, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
public fun ULongArray.fill(element: ULong, fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
storage.fill(element.toLong(), fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
public expect fun UByteArray.fill(element: UByte, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
public fun UByteArray.fill(element: UByte, fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
storage.fill(element.toByte(), fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills original array with the provided value.
|
||||
* Fills this array or its subrange with the specified [element] value.
|
||||
*
|
||||
* @param fromIndex the start of the range (inclusive), 0 by default.
|
||||
* @param toIndex the end of the range (exclusive), size of this array by default.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
|
||||
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
public expect fun UShortArray.fill(element: UShort, fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
public fun UShortArray.fill(element: UShort, fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
storage.fill(element.toShort(), fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the range of valid indices for the array.
|
||||
|
||||
Reference in New Issue
Block a user