Has AA a bad implementation?

welkam wwwelkam at gmail.com
Fri Feb 12 12:48:30 UTC 2021


On Friday, 12 February 2021 at 12:41:32 UTC, frame wrote:
> Talking about this:
>
> aaA.d: 157
>> void clear() pure nothrow
>> {
>>    import core.stdc.string : memset;
>>    // clear all data, but don't change bucket array length
>>    memset(&buckets[firstUsed], 0, (buckets.length - firstUsed) 
>> * Bucket.sizeof);
>>    deleted = used = 0;
>>    firstUsed = cast(uint) dim;
>> }
>
> I see this is for performance but it also means that an 
> associative array never frees the memory it has allocated for 
> life time - or I'm wrong? I am missing a real empty() method 
> here.

There can be slices that point to the memory owned by this array 
so you cant just free it. If you want manually manage the memory 
then you should look at dub for different containers.


More information about the Digitalmars-d mailing list