# 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)

*** ** * ** ***


```
public class ShuffleOrder.DefaultShuffleOrder implements ShuffleOrder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#DefaultShuffleOrder(int)(int length)` Creates an instance with a specified length. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#DefaultShuffleOrder(int,long)(int length, long randomSeed)` Creates an instance with a specified length and the specified random seed. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/ShuffleOrder.DefaultShuffleOrder#DefaultShuffleOrder(int[],long)(int[] shuffledIndices, long randomSeed)` Creates an instance with a specified shuffle order and the specified random seed. |

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

| ### Inherited methods |
|---|
| From [androidx.media3.exoplayer.source.ShuffleOrder](https://developer.android.com/reference/androidx/media3/exoplayer/source/ShuffleOrder) |---|---| | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ShuffleOrder` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ShuffleOrder#cloneAndMove(int,int,int)(int indexFrom, int indexToExclusive, int newIndexFrom)` Returns a copy of the shuffle order to be used after a move. | | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ShuffleOrder` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ShuffleOrder#cloneAndSet(int,int)(int insertionCount, int startIndex)` Returns a copy of the shuffle order with all elements replaced. | |

## Public constructors

### DefaultShuffleOrder

```
public DefaultShuffleOrder(int length)
```

Creates an instance with a specified length.

| Parameters |
|---|---|
| `int length` | The length of the shuffle order. |

### DefaultShuffleOrder

```
public DefaultShuffleOrder(int length, long randomSeed)
```

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 |
|---|---|
| `int length` | The length of the shuffle order. |
| `long randomSeed` | A random seed. |

### DefaultShuffleOrder

```
public DefaultShuffleOrder(int[] shuffledIndices, long randomSeed)
```

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

| Parameters |
|---|---|
| `int[] shuffledIndices` | The shuffled indices to use as order. |
| `long randomSeed` | A random seed. |

## Public methods

### cloneAndClear

```
public ShuffleOrder cloneAndClear()
```

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

### cloneAndInsert

```
public ShuffleOrder cloneAndInsert(int insertionIndex, int insertionCount)
```

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

| Parameters |
|---|---|
| `int insertionIndex` | The index in the unshuffled order at which elements are inserted. |
| `int insertionCount` | The number of elements inserted at `insertionIndex`. |

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

### cloneAndRemove

```
public ShuffleOrder cloneAndRemove(int indexFrom, int indexToExclusive)
```

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

| Parameters |
|---|---|
| `int indexFrom` | The starting index in the unshuffled order of the range to remove. |
| `int indexToExclusive` | The smallest index (must be greater or equal to `indexFrom`) that will not be removed. |

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

### getFirstIndex

```
public int getFirstIndex()
```

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

### getLastIndex

```
public int getLastIndex()
```

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

### getLength

```
public int getLength()
```

Returns length of shuffle order.

### getNextIndex

```
public int getNextIndex(int index)
```

Returns the next index in the shuffle order.

| Parameters |
|---|---|
| `int index` | An index. |

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

### getPreviousIndex

```
public int getPreviousIndex(int index)
```

Returns the previous index in the shuffle order.

| Parameters |
|---|---|
| `int index` | An index. |

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