Honey, I sped up the associated array

Walter Bright newshound at digitalmars.com
Fri Oct 13 12:05:02 PDT 2006


Lionello Lunesu wrote:
> The size of the AA's internal array is the biggest factor, I've noticed. 

Not exactly, it's the number of collisions that matters, and the size of 
the array influences this as well as the hash algorithm. For 
mathematical reasons I do not understand, taking the remainder of 
division by a prime number gives the most even 'spread' across the 
array, minimizing collisions for a given array size.

> The old AA uses that static list of primes (half of which, 
> in fact, are never being used; see thread in D.learn).

It used to, the algorithm changed and the table wasn't updated.



More information about the Digitalmars-d mailing list