AA.remove in foreach && AA = new vs cleaning
Saaa
empty at needmail.com
Wed Oct 21 20:06:47 PDT 2009
Is there anything with removing the current key in a foreach?
foreach (K k, ; aa)
{
..
aa.remove(k);
}
What if it isn't the current key?
If the iteration is generated on the fly it shouldn't be a problem, right?
&&
Is it better to new an AA or empty(.remove) it on the fly if you loop over
all the keys anyways?
That is, I need an similar empty AA the next iteration :)
Removing every element takes of course as many operations as keys, but
filling the array won't take
as many memory allocations, as the gc doesn't return the key allocations. Am
I making any sense here? :D
More information about the Digitalmars-d-learn
mailing list