Static associative arrays?

Dan murpsoft at hotmail.com
Wed Mar 14 09:19:56 PDT 2007


> Yep, what we need, is sort of 'AA Literals' which can be used to 
> initialize either static or dynamic associative array.
> 
> -- 
> serg.

Well, currently dynamic arrays are initialized by dup'ing a static array, or by assigning one thing at a time (ick).

Associative Arrays should be no different really.  I think the issue with this is that the hash function he's using runs on pointers, which means you can't build the hashtables until runtime and therefore can't have static associative arrays without changes.  Am I correct?

For my needs (small associative arrays as objects), I would prefer not to use hashing, and instead use a median-left, low-left binary search array (x << 1 goes left, x << 1 + 1 goes right, and cache stays coherent.)  The plan was to again use the char[] structs (not the actual strings) I'm going to look into what I can do to override Associative Arrays in D.

On that note, has anyone found evidence of a median-left low-left binary search array?  I think (currently) I may be the first to use such a device, in spite of it's obviousness?  I'd love to hear evidence otherwise.

Thanks,
Dan



More information about the Digitalmars-d mailing list