Associative arrays question

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Dec 31 06:47:39 PST 2007


"Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message 
news:flavc0$1f0e$1 at digitalmars.com...

>> I'm assuming that .rehash isn't really going to do much considering I'm 
>> using ints as the keys?
>
> The AA implementation in D uses a form of separate chaining where each 
> slot in the hashtable points to a data structure used to resolve 
> collisions.  In the case of the D AAs, it uses a binary tree at each slot.
>
> What rehash does is makes the hash table bigger and reinserts all the keys 
> into it.  If it's bigger in one direction, it'll be smaller in the 
> other --  that is, the average depth of each tree will get smaller, maybe 
> even as small as 1 node for each tree, making lookups faster.

I forgot where I was headed with this :)  the thing is that it doesn't 
really matter what type your keys are, .rehash should yield about the same 
speedup. 




More information about the Digitalmars-d-learn mailing list