Steven Schveighoffer wrote:
> Yes, behavior is undefined.
>
> from http://digitalmars.com/d/2.0/statement.html#ForeachStatement :
>
> "The aggregate must be loop invariant, meaning that elements to the 
> aggregate cannot be added or removed from it in the [loop body]"
I suspect removing the current key isn't a problem in the current 
implementation;
Been using it quite a lot without any problems :)
But I've changed everything to new the array afterwards as I deleted all the 
keys anyways.
>
> I have gotten around this in dcollections by removing elements outside the 
> loop body.  See for example the keypurge function of HashMap 
> (http://www.dsource.org/projects/dcollections/docs/current/dcollections.HashMap.html)
Do you add the ones to be deleted to a dynamic array or do you loop
over all elements afterwards? I expect the first :)




Reply via email to