Stay organized with collections Save and categorize content based on your preferences.

ShuffleOrder

@UnstableApi
public interface ShuffleOrder

Known direct subclasses
FakeShuffleOrder

Fake ShuffleOrder which returns a reverse order.

ShuffleOrder.DefaultShuffleOrder

The default ShuffleOrder implementation for random shuffle order.

ShuffleOrder.UnshuffledShuffleOrder

A ShuffleOrder implementation which does not shuffle.


Shuffled order of indices.

The shuffle order must be immutable to ensure thread safety.

The order must be consistent when traversed both forwards and backwards.

Summary

Nested types

public class ShuffleOrder.DefaultShuffleOrder implements ShuffleOrder

The default ShuffleOrder implementation for random shuffle order.

public final class ShuffleOrder.UnshuffledShuffleOrder implements ShuffleOrder

A ShuffleOrder implementation which does not shuffle.

Public methods

abstract ShuffleOrder

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

abstract ShuffleOrder
cloneAndInsert(int insertionIndex, int insertionCount)

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

abstract ShuffleOrder
cloneAndRemove(int indexFrom, int indexToExclusive)

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

abstract int

Returns the first index in the shuffle order, or INDEX_UNSET if the shuffle order is empty.

abstract int

Returns the last index in the shuffle order, or INDEX_UNSET if the shuffle order is empty.

abstract int

Returns length of shuffle order.

abstract int
getNextIndex(int index)

Returns the next index in the shuffle order.

abstract int
getPreviousIndex(int index)

Returns the previous index in the shuffle order.

Public methods

cloneAndClear

abstract ShuffleOrder cloneAndClear()

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

cloneAndInsert

abstract 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
ShuffleOrder

A copy of this ShuffleOrder with newly inserted elements.

cloneAndRemove

abstract 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
ShuffleOrder

A copy of this ShuffleOrder without the elements in the removed range.

getFirstIndex

abstract int getFirstIndex()

Returns the first index in the shuffle order, or INDEX_UNSET if the shuffle order is empty.

getLastIndex

abstract int getLastIndex()

Returns the last index in the shuffle order, or INDEX_UNSET if the shuffle order is empty.

getLength

abstract int getLength()

Returns length of shuffle order.

getNextIndex

abstract int getNextIndex(int index)

Returns the next index in the shuffle order.

Parameters
int index

An index.

Returns
int

The index after index, or INDEX_UNSET if index is the last element.

getPreviousIndex

abstract int getPreviousIndex(int index)

Returns the previous index in the shuffle order.

Parameters
int index

An index.

Returns
int

The index before index, or INDEX_UNSET if index is the first element.