This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
/** | |
* Generates a sequence of pseudo-random numbers such that they never repeat. Can handle sequence sizes up to | |
* length Int.MAX_VALUE. Will throw exceptions if you ask for more than that; maps the entire [0, Integer.MAX_VALUE] | |
* range onto itself but in a random order | |
* <link>http://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/</link> | |
*/ | |
public class PreshingRandomSequence { | |
public static final int MAX_INT_PRIME = 2147483587; |