mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
Fixing bug in CollectionExtensions RemoveAll method
This commit is contained in:
@@ -9,23 +9,6 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class CollectionExtensions
|
public static class CollectionExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Removes items matching the predicate.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="extends"></param>
|
|
||||||
/// <param name="predicate"></param>
|
|
||||||
public static void RemoveAll<T>(this ICollection<T> extends, Func<T, bool> predicate)
|
|
||||||
{
|
|
||||||
if (extends == null)
|
|
||||||
throw new ArgumentNullException("extends");
|
|
||||||
|
|
||||||
if (predicate == null)
|
|
||||||
throw new ArgumentNullException("predicate");
|
|
||||||
|
|
||||||
extends.RemoveAll(extends.Where(predicate).ToArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes all of the items from the other collection.
|
/// Removes all of the items from the other collection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -40,7 +23,24 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
if (other == null)
|
if (other == null)
|
||||||
throw new ArgumentNullException("other");
|
throw new ArgumentNullException("other");
|
||||||
|
|
||||||
foreach (T item in other)
|
extends.RemoveAll(i => other.Contains(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes items matching the predicate.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="extends"></param>
|
||||||
|
/// <param name="predicate"></param>
|
||||||
|
public static void RemoveAll<T>(this ICollection<T> extends, Func<T, bool> 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);
|
extends.Remove(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace ICD.Common.Utils.Xml
|
|||||||
throw new ArgumentNullException("extends");
|
throw new ArgumentNullException("extends");
|
||||||
|
|
||||||
if (!extends.HasAttributes)
|
if (!extends.HasAttributes)
|
||||||
return new IcdXmlAttribute[0];
|
return Enumerable.Empty<IcdXmlAttribute>();
|
||||||
|
|
||||||
List<IcdXmlAttribute> attributes = new List<IcdXmlAttribute>();
|
List<IcdXmlAttribute> attributes = new List<IcdXmlAttribute>();
|
||||||
while (extends.MoveToNextAttribute())
|
while (extends.MoveToNextAttribute())
|
||||||
|
|||||||
Reference in New Issue
Block a user