# FakeShuffleOrder

# FakeShuffleOrder

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/test/utils/FakeShuffleOrder "View this page in Java")

<br />

```
@UnstableApi
class FakeShuffleOrder : ShuffleOrder
```

<br />

*** ** * ** ***

Fake[ShuffleOrder](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder)which returns a reverse order. This order is thus deterministic but different from the original order.

## Summary

|                                                                                                    ### Public constructors                                                                                                    |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [FakeShuffleOrder](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeShuffleOrder#FakeShuffleOrder(int))`(length: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` |

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

|                            ### Public properties                            |
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [length](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeShuffleOrder#length()) |

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

## Public constructors

### FakeShuffleOrder

```
FakeShuffleOrder(length: Int)
```  

## 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: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The index in the unshuffled order at which elements are inserted. |
| `insertionCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The number of elements inserted at`insertionIndex`.               |

|                                                     Returns                                                     |
|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ShuffleOrder](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder)`!` | A copy of this[ShuffleOrder](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: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)        | The starting index in the unshuffled order of the range to remove.                    |
| `indexToExclusive: `[Int](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                                                     |
|-----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ShuffleOrder](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ShuffleOrder)`!` | A copy of this[ShuffleOrder](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[INDEX_UNSET](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[INDEX_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET())if the shuffle order is empty.  

### getNextIndex

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

Returns the next index in the shuffle order.  

|                                      Parameters                                      |
|--------------------------------------------------------------------------------------|-----------|
| `index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | An index. |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The index after`index`, or[INDEX_UNSET](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: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | An index. |

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

## Public properties

### length

```
val length: Int
```