public class FisherYates extends Object
Combined with the ParkMiller Random Number Generator
implementation on this library, cross-platform reproducible results
can be guaranteed.
Verified compatible libraries are:
Using other libraries won't guarantee reproducible results.
The main difference between this implementation and the native
Collections.shuffle(java.util.List<?>) consist on the way this one
selects which elements to swap on each iteration. See inlined comments
for more information.
| Constructor and Description |
|---|
FisherYates() |
| Modifier and Type | Method and Description |
|---|---|
static <T> List<T> |
shuffle(List<T> input)
Shuffle the input list of elements using a
Random Random
Number Generator instance to decide which positions get swapped
on each iteration. |
static <T> List<T> |
shuffle(List<T> input,
long seed)
Shuffle the input list of elements using a
ParkMiller Random
Number Generator instance to decide which positions get swapped
on each iteration. |
static <T> List<T> |
shuffle(List<T> input,
Random random)
Shuffle the input list of elements using a
Random Random
Number Generator instance to decide which positions get swapped
on each iteration. |
public static <T> List<T> shuffle(List<T> input)
Random Random
Number Generator instance to decide which positions get swapped
on each iteration.public static <T> List<T> shuffle(List<T> input, long seed)
ParkMiller Random
Number Generator instance to decide which positions get swapped
on each iteration.
Use the same seed for the RNGs when reproducible results are required.
public static <T> List<T> shuffle(List<T> input, Random random)
Random Random
Number Generator instance to decide which positions get swapped
on each iteration.
Use the same seed for the RNGs when reproducible results are required.
Warning: It's recommended to use shuffle(List, long)
instead, to ensure you are using a cross-platform RNG like ParkMiller.
Copyright © 2021. All rights reserved.