public void RemoveFunctionsExceptFor(FunctionNameDictionary functions) { FunctionList toBeRemoved = new FunctionList(); foreach (Function f in this) { if (!functions.ContainsKey(f.Name)) { toBeRemoved.Add(f); } else { functions.MarkAsMatched(f.Name); } } foreach (Function f in toBeRemoved) { this.Remove(f); } }