Associative arrays question

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Dec 31 06:46:25 PST 2007


"Robby" <robby.lansaw at gmail.com> wrote in message 
news:flahhv$ibd$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.

> Any real performance pitfalls when it comes
to
> associative arrays that's not been documented to watch for?

As long as you don't need to _duplicate_ them they should be quite 
performant. 




More information about the Digitalmars-d-learn mailing list