# ShuffleOrder.DefaultShuffleOrder

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/source/ShuffleOrder.java+class:androidx.media3.exoplayer.source.ShuffleOrder.DefaultShuffleOrder)

*** ** * ** ***

<br />

```
class ShuffleOrder.DefaultShuffleOrder : ShuffleOrder
```

<br />

*** ** * ** ***

The default `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder` implementation for random shuffle order.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#DefaultShuffleOrder(int)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates an instance with a specified length. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#DefaultShuffleOrder(int,long)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, randomSeed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Creates an instance with a specified length and the specified random seed. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#DefaultShuffleOrder(int[],long)(shuffledIndices: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!, randomSeed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Creates an instance with a specified shuffle order and the specified random seed. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#cloneAndClear()()` Returns a copy of the shuffle order with all elements removed. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#cloneAndInsert(int,int)(insertionIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, insertionCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a copy of the shuffle order with newly inserted elements. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#cloneAndRemove(int,int)(indexFrom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, indexToExclusive: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a copy of the shuffle order with a range of elements removed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#getFirstIndex()()` Returns the first index in the shuffle order, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the shuffle order is empty. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#getLastIndex()()` Returns the last index in the shuffle order, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the shuffle order is empty. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#getLength()()` Returns length of shuffle order. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#getNextIndex(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the next index in the shuffle order. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#getPreviousIndex(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the previous index in the shuffle order. |

### Inherited functions

From [androidx.media3.exoplayer.source.ShuffleOrder](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder) `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder#cloneAndMove(int,int,int)(indexFrom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, indexToExclusive: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, newIndexFrom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Returns a copy of the shuffle order to be used after a move.
`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder#cloneAndSet(int,int)(insertionCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, startIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Returns a copy of the shuffle order with all elements replaced.

## Public constructors

### DefaultShuffleOrder

```
DefaultShuffleOrder(length: Int)
```

Creates an instance with a specified length.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the shuffle order. |

### DefaultShuffleOrder

```
DefaultShuffleOrder(length: Int, randomSeed: Long)
```

Creates an instance with a specified length and the specified random seed. Shuffle orders of the same length initialized with the same random seed are guaranteed to be equal.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the shuffle order. |
| `randomSeed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | A random seed. |

### DefaultShuffleOrder

```
DefaultShuffleOrder(shuffledIndices: IntArray<Int>!, randomSeed: Long)
```

Creates an instance with a specified shuffle order and the specified random seed. The random seed is used for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#cloneAndInsert(int,int)` invocations.

| Parameters |
|---|---|
| `shuffledIndices: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | The shuffled indices to use as order. |
| `randomSeed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | A random seed. |

## Public functions

### cloneAndClear

```
fun cloneAndClear(): ShuffleOrder!
```

Returns a copy of the shuffle order with all elements removed.

### cloneAndInsert

```
fun cloneAndInsert(insertionIndex: Int, insertionCount: Int): ShuffleOrder!
```

Returns a copy of the shuffle order with newly inserted elements.

| Parameters |
|---|---|
| `insertionIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index in the unshuffled order at which elements are inserted. |
| `insertionCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of elements inserted at `insertionIndex`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder!` | A copy of this `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder` with newly inserted elements. |

### cloneAndRemove

```
fun cloneAndRemove(indexFrom: Int, indexToExclusive: Int): ShuffleOrder!
```

Returns a copy of the shuffle order with a range of elements removed.

| Parameters |
|---|---|
| `indexFrom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The starting index in the unshuffled order of the range to remove. |
| `indexToExclusive: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The smallest index (must be greater or equal to `indexFrom`) that will not be removed. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder!` | A copy of this `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder` without the elements in the removed range. |

### getFirstIndex

```
fun getFirstIndex(): Int
```

Returns the first index in the shuffle order, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the shuffle order is empty.

### getLastIndex

```
fun getLastIndex(): Int
```

Returns the last index in the shuffle order, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the shuffle order is empty.

### getLength

```
fun getLength(): Int
```

Returns length of shuffle order.

### getNextIndex

```
fun getNextIndex(index: Int): Int
```

Returns the next index in the shuffle order.

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | An index. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index after `index`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if `index` is the last element. |

### getPreviousIndex

```
fun getPreviousIndex(index: Int): Int
```

Returns the previous index in the shuffle order.

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | An index. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index before `index`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if `index` is the first element. |