Class ShuffleOrder.DefaultShuffleOrder
- java.lang.Object
-
- com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder
-
- All Implemented Interfaces:
ShuffleOrder
- Enclosing interface:
- ShuffleOrder
public static class ShuffleOrder.DefaultShuffleOrder extends Object implements ShuffleOrder
The defaultShuffleOrder
implementation for random shuffle order.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.source.ShuffleOrder
ShuffleOrder.DefaultShuffleOrder, ShuffleOrder.UnshuffledShuffleOrder
-
-
Constructor Summary
Constructors Constructor Description DefaultShuffleOrder(int length)
Creates an instance with a specified length.DefaultShuffleOrder(int[] shuffledIndices, long randomSeed)
Creates an instance with a specified shuffle order and the specified random seed.DefaultShuffleOrder(int length, long randomSeed)
Creates an instance with a specified length and the specified random seed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ShuffleOrder
cloneAndClear()
Returns a copy of the shuffle order with all elements removed.ShuffleOrder
cloneAndInsert(int insertionIndex, int insertionCount)
Returns a copy of the shuffle order with newly inserted elements.ShuffleOrder
cloneAndRemove(int indexFrom, int indexToExclusive)
Returns a copy of the shuffle order with a range of elements removed.int
getFirstIndex()
Returns the first index in the shuffle order, orC.INDEX_UNSET
if the shuffle order is empty.int
getLastIndex()
Returns the last index in the shuffle order, orC.INDEX_UNSET
if the shuffle order is empty.int
getLength()
Returns length of shuffle order.int
getNextIndex(int index)
Returns the next index in the shuffle order.int
getPreviousIndex(int index)
Returns the previous index in the shuffle order.
-
-
-
Constructor Detail
-
DefaultShuffleOrder
public DefaultShuffleOrder(int length)
Creates an instance with a specified length.- Parameters:
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:
length
- The length of the shuffle order.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 forcloneAndInsert(int, int)
invocations.- Parameters:
shuffledIndices
- The shuffled indices to use as order.randomSeed
- A random seed.
-
-
Method Detail
-
getLength
public int getLength()
Description copied from interface:ShuffleOrder
Returns length of shuffle order.- Specified by:
getLength
in interfaceShuffleOrder
-
getNextIndex
public int getNextIndex(int index)
Description copied from interface:ShuffleOrder
Returns the next index in the shuffle order.- Specified by:
getNextIndex
in interfaceShuffleOrder
- Parameters:
index
- An index.- Returns:
- The index after
index
, orC.INDEX_UNSET
ifindex
is the last element.
-
getPreviousIndex
public int getPreviousIndex(int index)
Description copied from interface:ShuffleOrder
Returns the previous index in the shuffle order.- Specified by:
getPreviousIndex
in interfaceShuffleOrder
- Parameters:
index
- An index.- Returns:
- The index before
index
, orC.INDEX_UNSET
ifindex
is the first element.
-
getLastIndex
public int getLastIndex()
Description copied from interface:ShuffleOrder
Returns the last index in the shuffle order, orC.INDEX_UNSET
if the shuffle order is empty.- Specified by:
getLastIndex
in interfaceShuffleOrder
-
getFirstIndex
public int getFirstIndex()
Description copied from interface:ShuffleOrder
Returns the first index in the shuffle order, orC.INDEX_UNSET
if the shuffle order is empty.- Specified by:
getFirstIndex
in interfaceShuffleOrder
-
cloneAndInsert
public ShuffleOrder cloneAndInsert(int insertionIndex, int insertionCount)
Description copied from interface:ShuffleOrder
Returns a copy of the shuffle order with newly inserted elements.- Specified by:
cloneAndInsert
in interfaceShuffleOrder
- Parameters:
insertionIndex
- The index in the unshuffled order at which elements are inserted.insertionCount
- The number of elements inserted atinsertionIndex
.- Returns:
- A copy of this
ShuffleOrder
with newly inserted elements.
-
cloneAndRemove
public ShuffleOrder cloneAndRemove(int indexFrom, int indexToExclusive)
Description copied from interface:ShuffleOrder
Returns a copy of the shuffle order with a range of elements removed.- Specified by:
cloneAndRemove
in interfaceShuffleOrder
- Parameters:
indexFrom
- The starting index in the unshuffled order of the range to remove.indexToExclusive
- The smallest index (must be greater or equal toindexFrom
) that will not be removed.- Returns:
- A copy of this
ShuffleOrder
without the elements in the removed range.
-
cloneAndClear
public ShuffleOrder cloneAndClear()
Description copied from interface:ShuffleOrder
Returns a copy of the shuffle order with all elements removed.- Specified by:
cloneAndClear
in interfaceShuffleOrder
-
-