Re: RFC: getting a unique integer value


Subject: Re: RFC: getting a unique integer value
From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Mon Oct 15 2001 - 19:34:04 CDT


On Mon, 15 Oct 2001, Dom Lachowicz wrote:

> Quoting Mike Nordell <tamlin@algonet.se>:
>
>
> > I agree with Hub here. If we are to get unique numbers used as IDs for
> > something, anything, why not use an incrementing ID? Random numbers
> > (even
> > that this is no RNG, it's like most implementations a PRNG) are used for
> > quite different purposes. We don't really _need_ random numbers, do we?
> > Isn't what we actually need unique IDs, or?
>
> Seriously... We don't need random numbers here, just unique ones. Here's my
> proposed replacement, which is also a helluva lot faster than any known good
> random number generator:
>
> UT_uint32 UT_newNumber ()
> {
> static UT_uint32 theNum = 0;
> //MUTEX_PROTECT this variable someday soon
> return theNum++;
> }
>
> Anyone opposed to me checking this into ut_math?
>

I want to reserve the first 10000 ID's for future use with lists. BTW the
RTF SPEC DOES ask for random 32 bit ID's for some purposes. I forget
which right now though.

Cheers

Martin



This archive was generated by hypermail 2b25 : Mon Oct 15 2001 - 19:34:18 CDT