Do AAs allocate on removal?

Mike Parker aldacron at gmail.com
Sat Dec 7 21:49:16 PST 2013


On Saturday, 7 December 2013 at 19:04:19 UTC, Gerrit Wichert 
wrote:

>  Seems to work, but I'm not shure if it is save to remove 
> entrys while iterating. Can't find any advise at this.
>

It's not when you're iterating the aa directly. You'll probably 
want something like this:

auto keys = objects.keys;
foreach( i, val; objects.values ) {
     if( val is null ) {
         objects.remove( keys[ i ]);
     }
}


More information about the Digitalmars-d mailing list