is Associative Arrays good for integer type as key?

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Nov 14 21:31:33 PST 2006


"%u" <newbie at dd.com> wrote in message news:ejdukb$otl$1 at digitaldaemon.com...
> And what's the internal implementation of Associative Arrays for things 
> like:
>
> int[short] hashtable;
>
> Is it a tree, or raw array with linked-list?

All associative arrays in D, no matter the key or value types, are 
implemented as a closed-addressed hash table with binary trees at each hash 
table location to resolve collisions (as opposed to the more common 
linked-list at each location).  If you'd like, you can see how AAs are 
implemented in /dmd/src/phobos/internal/aaA.d, and you can see how all the 
hashes are computed for the various types in the phobos/typeinfo directory. 
For shorts, the hash is simply the value itself. 





More information about the Digitalmars-d-learn mailing list