rotateLeft

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

Rotates the Array to the left by specified distance.

Example:

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

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


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

Rotates the ByteArray to the left by specified distance.

Example:

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

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


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

Rotates the ShortArray to the left by specified distance.

Example:

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

Since

1.1.0

Parameters

n

number of elements rotate

See also

shortArrayOf

Throws

IllegalArgumentException

if n is negative or zero.


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

Rotates the CharArray to the left by specified distance.

Example:

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

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


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

Rotates the IntArray to the left by specified distance.

Example:

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

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


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

Rotates the LongArray to the left by specified distance.

Example:

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

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.


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

Rotates the FloatArray to the left by specified distance.

Example:

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

Since

1.1.0

Parameters

n

number of elements rotate

See also

floatArrayOf

Throws

IllegalArgumentException

if n is negative or zero.


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

Rotates the DoubleArray to the left by specified distance.

Example:

doubleArrayOf(1.0, 2.0, 3.0, 4.0, 5.0).rotateLeft(2) // [4.0, 5.0, 1.0, 2.0, 3.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.rotateLeft(n: Int = 1): BooleanArray

Rotates the BooleanArray to the left by specified distance.

Example:

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

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>.rotateLeft(n: Int = 1): List<T>

Rotates the Iterable to the left by specified distance.

Example:

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

Since

1.1.0

Parameters

n

number of elements rotate

See also

Throws

IllegalArgumentException

if n is negative or zero.