If there are only a few numbers, less than 100, I think I solution could be create a boolean array and once you get a number, set the position of the array to true. I don't think that it takes long time until all the numbers appear. Hope it helps!
Cheers!