ShuffleOrder.DefaultShuffleOrder

class ShuffleOrder.DefaultShuffleOrder : ShuffleOrder


The default ShuffleOrder implementation for random shuffle order.

Summary

Public constructors

Creates an instance with a specified length.

DefaultShuffleOrder(length: Int, randomSeed: Long)

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

DefaultShuffleOrder(shuffledIndices: IntArray!, randomSeed: Long)

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

Public functions

ShuffleOrder!

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

ShuffleOrder!
cloneAndInsert(insertionIndex: Int, insertionCount: Int)

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

ShuffleOrder!
cloneAndRemove(indexFrom: Int, indexToExclusive: Int)

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(index: Int)

Returns the next index in the shuffle order.

Int

Returns the previous index in the shuffle order.

Public constructors

DefaultShuffleOrder

DefaultShuffleOrder(length: Int)

Creates an instance with a specified length.

Parameters
length: Int

The length of the shuffle order.

DefaultShuffleOrder

DefaultShuffleOrder(length: Int, randomSeed: Long)

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: Int

The length of the shuffle order.

randomSeed: Long

A random seed.

DefaultShuffleOrder

DefaultShuffleOrder(shuffledIndices: IntArray!, randomSeed: Long)

Creates an instance with a specified shuffle order and the specified random seed. The random seed is used for cloneAndInsert invocations.

Parameters
shuffledIndices: IntArray!

The shuffled indices to use as order.

randomSeed: Long

A random seed.

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

The index in the unshuffled order at which elements are inserted.

insertionCount: Int

The number of elements inserted at insertionIndex.

Returns
ShuffleOrder!

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

The starting index in the unshuffled order of the range to remove.

indexToExclusive: Int

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

fun getFirstIndex(): Int

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

getLastIndex

fun getLastIndex(): Int

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

getLength

fun getLength(): Int

Returns length of shuffle order.

getNextIndex

fun getNextIndex(index: Int): Int

Returns the next index in the shuffle order.

Parameters
index: Int

An index.

Returns
Int

The index after index, or 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

An index.

Returns
Int

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