All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.psjava.algo.sequence.Shuffler Maven / Gradle / Ivy

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