One alternative is to do random selection (repeating until successful) for the first X percent of N, then switching to scanning through the whole bitmap until you find the rand(number-remaining)'th remaining number. Some benchmarks would be needed to pick a good X; I'd guess 90%.
In reply to Re: Generating 0 .. N Randomly and Efficiently
by ysth
in thread Generating 0 .. N Randomly and Efficiently
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |