AA clear property

Marco Leise Marco.Leise at gmx.de
Sun Nov 6 02:09:46 PST 2011


Am 06.11.2011, 00:15 Uhr, schrieb Alex_Dovhal <alex_dovhal at yahoo.com>:

> "Marco Leise" <Marco.Leise at gmx.de> wrote:
>> Are you this Alex?
> yes.
>
>> As I understand it this function is defined in object_.d which is always
>> imported by default and can be called on an (associative) array through  
>> a
>> mechanism called "universal function call", that matches the part before
>> the dot with the first parameter of the function. This only works for
>> arrays. So I believe it is a free function (to invalidate/finalize a
>> variable) and not a property of an array at all.
>
> Thanks for clarification.
> So now my question and task changes.
> Is there a way to reuse previous memory occupied by AA, when I need to
> change all of it element?
> E.g. for dynamic arrays it's possible to make:
> dyn_arr.length = 0;
> assumeSafeAppend(dyn_arr);
> fill_new_values(dyn_arr);

No way I heard of. You could delete the entries one by one. :D
I guess setting all references to null is the easiest way to 'clear' an AA.


More information about the Digitalmars-d-learn mailing list