Here is what I am trying to do:
private readonly IDictionary<float, ICollection<IGameObjectController>> layers;
foreach (ICollection<IGameObjectController> layerSet in layers.Values)
{
foreach (IGameObjectController controller in layerSet)
{
if (controller.Model.DefinedInVariant)
{
layerSet.Remove(controller);
}
}
}
Of course, this doesn't work, because it will cause a concurrent modification exception. (Is there an equivalent of Java's safe removal operation on some iterators?) How can I do this correctly, or with LINQ?