Check for index-out-of-bound in elementAt function (KT-30051)
This commit is contained in:
@@ -14,6 +14,96 @@ package kotlin.collections
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun <T> Array<out T>.elementAt(index: Int): T {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun ByteArray.elementAt(index: Int): Byte {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun ShortArray.elementAt(index: Int): Short {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun IntArray.elementAt(index: Int): Int {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun LongArray.elementAt(index: Int): Long {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun FloatArray.elementAt(index: Int): Float {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun DoubleArray.elementAt(index: Int): Double {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun BooleanArray.elementAt(index: Int): Boolean {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun CharArray.elementAt(index: Int): Char {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements that are instances of specified class.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,16 @@ package kotlin.text
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Returns a character at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this char sequence.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun CharSequence.elementAt(index: Int): Char {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [SortedSet][java.util.SortedSet] of all characters.
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,54 @@ package kotlin.collections
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun UIntArray.elementAt(index: Int): UInt {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun ULongArray.elementAt(index: Int): ULong {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun UByteArray.elementAt(index: Int): UByte {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
|
||||
*
|
||||
* @sample samples.collections.Collections.Elements.elementAt
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun UShortArray.elementAt(index: Int): UShort {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user