I want to create a shuffled set of integers such that:
- Given the same seed, the shuffle will be the same every time
- As I iterate through, every number in the shuffled set will be used exactly once before repeating itself
- Will work for large sets (I want all numbers between 0 and 2 billion)
- Will generate between a range, for example, 100 to 150.
This option gives a great solution if you want, say, all of the numbers between 0 and a specified number: Generating Shuffled Range Using a PRNG Rather Than Shuffling
Any ideas?
You can use the exact same algorithm as the linked question. Just generate numbers between 0 and
upperBound - lowerBound + 1and addlowerBoundto the result.e.g. (using code from linked question):
If you want the sequence to repeat (shuffled differently each time), you can add a
while (true)around the iterator method body.