W3cubDocs

/Kotlin

reverse

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> Array<T>.reverse()
fun ByteArray.reverse()
fun ShortArray.reverse()
fun IntArray.reverse()
fun LongArray.reverse()
fun FloatArray.reverse()
fun DoubleArray.reverse()
fun BooleanArray.reverse()
fun CharArray.reverse()
@ExperimentalUnsignedTypes fun UIntArray.reverse()
@ExperimentalUnsignedTypes fun ULongArray.reverse()
@ExperimentalUnsignedTypes fun UByteArray.reverse()
@ExperimentalUnsignedTypes fun UShortArray.reverse()

Reverses elements in the array in-place.

Platform and version requirements: JVM (1.4), JS (1.4), Native (1.4)
fun <T> Array<T>.reverse(fromIndex: Int, toIndex: Int)
fun ByteArray.reverse(fromIndex: Int, toIndex: Int)
fun ShortArray.reverse(fromIndex: Int, toIndex: Int)
fun IntArray.reverse(fromIndex: Int, toIndex: Int)
fun LongArray.reverse(fromIndex: Int, toIndex: Int)
fun FloatArray.reverse(fromIndex: Int, toIndex: Int)
fun DoubleArray.reverse(fromIndex: Int, toIndex: Int)
fun BooleanArray.reverse(fromIndex: Int, toIndex: Int)
fun CharArray.reverse(fromIndex: Int, toIndex: Int)
@ExperimentalUnsignedTypes fun UIntArray.reverse(
    fromIndex: Int, 
    toIndex: Int)
@ExperimentalUnsignedTypes fun ULongArray.reverse(
    fromIndex: Int, 
    toIndex: Int)
@ExperimentalUnsignedTypes fun UByteArray.reverse(
    fromIndex: Int, 
    toIndex: Int)
@ExperimentalUnsignedTypes fun UShortArray.reverse(
    fromIndex: Int, 
    toIndex: Int)

Reverses elements of the array in the specified range in-place.

Parameters

fromIndex - the start of the range (inclusive) to reverse.

toIndex - the end of the range (exclusive) to reverse.

Exceptions

IndexOutOfBoundsException - if fromIndex is less than zero or toIndex is greater than the size of this array.

IllegalArgumentException - if fromIndex is greater than toIndex.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> MutableList<T>.reverse()

Reverses elements in the list in-place.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/reverse.html