D
David Combs
UG> my %seen ;
UG> while( 1 ) { $x = int rand( 100_000_000 ) ; $seen{$x} and next ;
UG> $seen{$x} = 1; print $x }
XJ> I'd be very surprised if Bit::Vector had faster performance, at least
XJ> until the other method started swapping.
It's C internally so performance is pretty good. But you're probably
right anyhow, I wasn't thinking.
UG> he said he wanted 1k random numbers out of a large range so a hash would
UG> be fine for that.
You're right, I wasn't paying enough attention.
Ted
What, you're saying a div and a mod (let's assume 64 bits, if integet) to
find the desired bit, versus dealing each time with a hash bucket to choose
an ensuing chain to hunt down through?
So you make the bucket-array longer, so the chains are short -- get it
long enough so only very, very few chains are longer than one (most
being zero) in length, and you're almost emulating the bit-vector
scheme, but taking up FAR FAR more space.
?
David