public static int [ ] shuffleIndices ( int length , RandomGenerator randomGenerator ) { // Initialize indices: final int [ ] indices = IntStream . range ( 0 , length ) . toArray ( ) ; // Shuffle the array: MathArrays . shuffle ( indices , randomGenerator ) ; // Done return shuffled indices: return indices ; }
Consumes the length of an array and returns its shuffled indices .