ShuffleOrder.DefaultShuffleOrder


public class ShuffleOrder.DefaultShuffleOrder implements ShuffleOrder


The default ShuffleOrder implementation for random shuffle order.

Summary

Public constructors

DefaultShuffleOrder(int length)

Creates an instance with a specified length.

DefaultShuffleOrder(int length, long randomSeed)

Creates an instance with a specified length and the specified random seed.

DefaultShuffleOrder(int[] shuffledIndices, long randomSeed)

Creates an instance with a specified shuffle order and the specified random seed.

Public methods

ShuffleOrder

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

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

int

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

int

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.

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

A copy of this 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
ShuffleOrder

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

getFirstIndex

public int getFirstIndex()

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

getLastIndex

public int getLastIndex()

Returns the last index in the shuffle order, or 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 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 INDEX_UNSET if index is the first element.