Interface ShuffleOrder
-
- All Known Implementing Classes:
FakeShuffleOrder
,ShuffleOrder.DefaultShuffleOrder
,ShuffleOrder.UnshuffledShuffleOrder
public interface ShuffleOrder
Shuffled order of indices.The shuffle order must be immutable to ensure thread safety.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ShuffleOrder.DefaultShuffleOrder
The defaultShuffleOrder
implementation for random shuffle order.static class
ShuffleOrder.UnshuffledShuffleOrder
AShuffleOrder
implementation which does not shuffle.
-
Method Summary
All Methods Instance Methods Abstract 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.
-
-
-
Method Detail
-
getLength
int getLength()
Returns length of shuffle order.
-
getNextIndex
int getNextIndex(int index)
Returns the next index in the shuffle order.- Parameters:
index
- An index.- Returns:
- The index after
index
, orC.INDEX_UNSET
ifindex
is the last element.
-
getPreviousIndex
int getPreviousIndex(int index)
Returns the previous index in the shuffle order.- Parameters:
index
- An index.- Returns:
- The index before
index
, orC.INDEX_UNSET
ifindex
is the first element.
-
getLastIndex
int getLastIndex()
Returns the last index in the shuffle order, orC.INDEX_UNSET
if the shuffle order is empty.
-
getFirstIndex
int getFirstIndex()
Returns the first index in the shuffle order, orC.INDEX_UNSET
if the shuffle order is empty.
-
cloneAndInsert
ShuffleOrder cloneAndInsert(int insertionIndex, int insertionCount)
Returns a copy of the shuffle order with newly inserted elements.- 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
ShuffleOrder cloneAndRemove(int indexFrom, int indexToExclusive)
Returns a copy of the shuffle order with a range of elements removed.- 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
ShuffleOrder cloneAndClear()
Returns a copy of the shuffle order with all elements removed.
-
-