public class FisherYatesKnuthShuffle<T extends java.lang.Comparable> extends java.lang.Object implements ShufflingEngine<T>
The Fisher-Yates algorithm (presented by Knuth in TAOCP) is both the canonical shuffling algorithm and asymptotically optimal (linear). The range provided for random-number generation changes at each step i.e. does not include what has been seen so far, which guarantees equal probability for all elements.
ARRAY_IS_EMPTY, DATA_TYPE_NOT_SUPPORTED_YET, DECIMAL_RADIX, DELIMITER_COMMA, ELEMENT_NOT_FOUND, LIST_IS_EMPTY, OPERATION_NOT_SUPPORTED_YET
Constructor and Description |
---|
FisherYatesKnuthShuffle() |
Modifier and Type | Method and Description |
---|---|
void |
shuffle(T[] objects) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRandomNumberInRange
checkArray, checkIntArray, checkList
public void shuffle(T[] objects)
shuffle
in interface ShufflingEngine<T extends java.lang.Comparable>