mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-12 11:15:12 +00:00
Fixing bug in CollectionExtensions RemoveAll method
This commit is contained in:
@@ -9,23 +9,6 @@ namespace ICD.Common.Utils.Extensions
|
||||
/// </summary>
|
||||
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>
|
||||
/// Removes all of the items from the other collection.
|
||||
/// </summary>
|
||||
@@ -40,7 +23,24 @@ namespace ICD.Common.Utils.Extensions
|
||||
if (other == null)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace ICD.Common.Utils.Xml
|
||||
throw new ArgumentNullException("extends");
|
||||
|
||||
if (!extends.HasAttributes)
|
||||
return new IcdXmlAttribute[0];
|
||||
return Enumerable.Empty<IcdXmlAttribute>();
|
||||
|
||||
List<IcdXmlAttribute> attributes = new List<IcdXmlAttribute>();
|
||||
while (extends.MoveToNextAttribute())
|
||||
|
||||
Reference in New Issue
Block a user