On Tue, Jun 26, 2001 at 05:19:18PM -0400, Richard Kasperowski wrote:
> > Yes, but that isn't really a problem because you'll just try again and
> > it happens sufficiently rarely that the extra time used is
> > insignificant. At least, that would be the theory.
> 
> 
> But what if it's not sufficiently rare?  In the worst case, it will take 
> O(n) time to find the next usable random number.  You might as well just 
> use a serial number; it will always take O(1) time to find the next 
> usable serial number.

That is true, but the cost of one element in the random algo is
(presumably) much much less than the cost of one element in the serial
algo (which at minimum requires communication with another bean). So
long as the assumption holds that the number of collisions is minimal,
O(n) worst case won't occur.

The random algo is faster than the other when it hits right away. If
it collides even once, it is already slower than the sequence algo. So
you need really big keys (compared to the size of the data set) to
make it work.

Cheers
        Bent D
-- 
Bent Dalager - [EMAIL PROTECTED] - http://www.pvv.org/~bcd
                                    powered by emacs

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to