org.psjava.algo.sequence.Shuffler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of psjava Show documentation
Show all versions of psjava Show documentation
Problem Solving Library for Java
The newest version!
package org.psjava.algo.sequence;
import java.util.Random;
import org.psjava.ds.array.ArraySwapper;
import org.psjava.ds.array.MutableArray;
import org.psjava.util.ZeroTo;
public class Shuffler {
private static final Random RANDOM = new Random();
public static void shuffle(MutableArray a) {
for (int i : ZeroTo.get(a.size()))
ArraySwapper.swap(a, i, i + RANDOM.nextInt(a.size() - i));
}
private Shuffler() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy