using System; using System.Collections.Generic; using System.Linq; namespace ICD.Common.Utils.Extensions { /// /// Extension methods for working with ICollections. /// public static class CollectionExtensions { /// /// Removes items matching the predicate. /// /// /// /// public static void RemoveAll(this ICollection extends, Func predicate) { if (extends == null) throw new ArgumentNullException("extends"); if (predicate == null) throw new ArgumentNullException("predicate"); extends.RemoveAll(extends.Where(predicate).ToArray()); } /// /// Removes all of the items from the other collection. /// /// /// /// public static void RemoveAll(this ICollection extends, IEnumerable other) { if (extends == null) throw new ArgumentNullException("extends"); if (other == null) throw new ArgumentNullException("other"); foreach (T item in other) extends.Remove(item); } } }