rotateRight

inline fun <T> Array<T>.rotateRight(n: Int = 1): Array<T>

Rotates the Array to the right by specified distance.

Example:

arrayOf(1, 2, 3, 4, 5).rotateRight(2) // [3, 4, 5, 1, 2]

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


@JvmOverloads
fun ByteArray.rotateRight(n: Int = 1): ByteArray

Rotates the ByteArray to the right by specified distance.

Example:

byteArrayOf(1, 2, 3, 4, 5).rotateRight(2) // [3, 4, 5, 1, 2]

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


@JvmOverloads
fun ShortArray.rotateRight(n: Int = 1): ShortArray

Rotates the ShortArray to the right by specified distance.

Example:

shortArrayOf(1, 2, 3, 4, 5).rotateRight(2) // [3, 4, 5, 1, 2]

Since

1.1.0

Parameters

n

number of elements rotate

See also

shortArrayOf

Throws

IllegalArgumentException

if n is negative or zero.


@JvmOverloads
fun CharArray.rotateRight(n: Int = 1): CharArray

Rotates the CharArray to the right by specified distance.

Example:

charArrayOf('a', 'b', 'c', 'd', 'e').rotateRight(2) // ['c', 'd', 'e', 'a', 'b']

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


@JvmOverloads
fun IntArray.rotateRight(n: Int = 1): IntArray

Rotates the IntArray to the right by specified distance.

Example:

intArrayOf(1, 2, 3, 4, 5).rotateRight(2) // [3, 4, 5, 1, 2]

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


@JvmOverloads
fun LongArray.rotateRight(n: Int = 1): LongArray

Rotates the LongArray to the right by specified distance.

Example:

longArrayOf(1L, 2L, 3L, 4L, 5L).rotateRight(2) // [3L, 4L, 5L, 1L, 2L]

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


@JvmOverloads
fun FloatArray.rotateRight(n: Int = 1): FloatArray

Rotates the FloatArray to the right by specified distance.

Example:

floatArrayOf(1F, 2F, 3F, 4F, 5F).rotateRight(2) // [3F, 4F, 5F, 1F, 2F]

Since

1.1.0

Parameters

n

number of elements rotate

See also

floatArrayOf

Throws

IllegalArgumentException

if n is negative or zero.


@JvmOverloads
fun DoubleArray.rotateRight(n: Int = 1): DoubleArray

Rotates the DoubleArray to the right by specified distance.

Example:

doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0).rotateRight(2) // [3.0, 4.0, 5.0, 1.0, 2.0]

Since

1.1.0

Parameters

n

number of elements rotate

See also

doubleArrayOf

Throws

IllegalArgumentException

if n is negative or zero.


@JvmOverloads
fun BooleanArray.rotateRight(n: Int = 1): BooleanArray

Rotates the BooleanArray to the right by specified distance.

Example:

booleanArrayOf(true, false, true, false, true).rotateRight(2) // [true, false, true, true, false]

Since

1.1.0

Parameters

n

number of elements rotate

See also

booleanArrayOf

Throws

IllegalArgumentException

if n is negative or zero.


inline fun <T> Iterable<T>.rotateRight(n: Int = 1): List<T>

Rotates the Iterable to the right by specified distance.

Example:

listOf(1, 2, 3, 4, 5).rotateRight(2) // [3, 4, 5, 1, 2]

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.