I've been trying to write an extension method to mimic List.RemoveAll(Predicate).
So far I've got this:
public static void RemoveAll<TKey,TValue>(this Dictionary<TKey,TValue> dict,
Predicate<KeyValuePair<TKey,TValue>> condition)
{
Dictionary<TKey,TValue> temp = new Dictionary<TKey,TValue>();
foreach (var item in dict)
{
if (!condition.Invoke(item))
temp.Add(item.Key, item.Value);
}
dict = temp;
}
Any pointers? Is this a completely naive implementation?