Fun project - faster associative array algorithm

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 7 16:18:34 PDT 2015


On 4/7/2015 3:59 PM, Andrei Alexandrescu wrote:
> On 4/7/15 3:56 PM, Walter Bright wrote:
>> On 4/7/2015 3:14 PM, Andrei Alexandrescu wrote:
>>> Arrays would need to move data. Current hashtables rely on values
>>> staying put.
>>
>> If the array of buckets were enhanced to include the hashes, the
>> key/value objects could stay untouched when the AA is grown. The
>> key/value objects would only be dereferenced if the hashes matched.
>
> Not sure I understand. What if the collision array needs to grow? That might
> move it. -- Andrei

The collision array is an array of pairs:

     KeyValue *kv;
     Hash_t hash;

growing the array moves those around, but the locations of the array elements 
are never exposed to the users. The addresses of kv are exposed, but those don't 
move.


More information about the Digitalmars-d mailing list