How can you loop over a fixed range of integers (say 100000-999999) in a difficult-to-predict order?
- assume the range may be large enough that it would be impractical to store every possible integer in an array or keep an array of every element you've found so far.
- you must hit every number in the range once and only once, and be able to tell when you've finished, i.e. there are no numbers left
I.e. I'd like something more elegant than just A) pick a random number and then B) check whether it's been used already and if so go back to step A, for the following reasons (unless you can convince me otherwise):
- that's really going to suck when you start running out of numbers
- telling whether you've run out of unused numbers may be prohibitively expensive
- this approach could also conceivably have concurrency issues if you have a lot of clients or threads trying to do it at the same time out of the same range