From f546a7d8c46da65ffdd5f50a81e689730b1a02bd Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Fri, 10 Nov 2017 14:32:13 -0500 Subject: [PATCH] Removing extremely slow collection extensions --- .../Extensions/CollectionExtensionsTest.cs | 34 ------------- .../Extensions/CollectionExtensions.cs | 50 ------------------- .../ICD.Common.Utils_SimplSharp.csproj | 1 - 3 files changed, 85 deletions(-) delete mode 100644 ICD.Common.Utils.Tests/Extensions/CollectionExtensionsTest.cs delete mode 100644 ICD.Common.Utils/Extensions/CollectionExtensions.cs diff --git a/ICD.Common.Utils.Tests/Extensions/CollectionExtensionsTest.cs b/ICD.Common.Utils.Tests/Extensions/CollectionExtensionsTest.cs deleted file mode 100644 index 44dd387..0000000 --- a/ICD.Common.Utils.Tests/Extensions/CollectionExtensionsTest.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Generic; -using ICD.Common.Utils.Extensions; -using NUnit.Framework; - -namespace ICD.Common.Utils.Tests.Extensions -{ - [TestFixture] - public sealed class CollectionExtensionsTest - { - [Test] - public void RemoveAllPredicateTest() - { - List a = new List {1, 2, 2, 3}; - List b = new List {2, 3}; - - ((ICollection)a).RemoveAll(i => b.Contains(i)); - - Assert.AreEqual(1, a.Count); - Assert.AreEqual(1, a[0]); - } - - [Test] - public void RemoveAllOtherTest() - { - List a = new List {1, 2, 2, 3}; - List b = new List {2, 3}; - - a.RemoveAll(b); - - Assert.AreEqual(1, a.Count); - Assert.AreEqual(1, a[0]); - } - } -} diff --git a/ICD.Common.Utils/Extensions/CollectionExtensions.cs b/ICD.Common.Utils/Extensions/CollectionExtensions.cs deleted file mode 100644 index ec831c9..0000000 --- a/ICD.Common.Utils/Extensions/CollectionExtensions.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using ICD.Common.Properties; - -namespace ICD.Common.Utils.Extensions -{ - /// - /// Extension methods for working with ICollections. - /// - public static class CollectionExtensions - { - /// - /// Removes all of the items from the other collection. - /// - /// - /// - /// - [PublicAPI] - public static void RemoveAll(this ICollection extends, IEnumerable other) - { - if (extends == null) - throw new ArgumentNullException("extends"); - - if (other == null) - throw new ArgumentNullException("other"); - - extends.RemoveAll(other.Contains); - } - - /// - /// Removes items matching the predicate. - /// - /// - /// - /// - [PublicAPI] - public static void RemoveAll(this ICollection extends, Func predicate) - { - if (extends == null) - throw new ArgumentNullException("extends"); - - if (predicate == null) - throw new ArgumentNullException("predicate"); - - foreach (T item in extends.Where(predicate).ToArray()) - extends.Remove(item); - } - } -} diff --git a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj index 7e4e1f1..1268405 100644 --- a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj +++ b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj @@ -113,7 +113,6 @@ -