diff --git a/ICD.Common.Utils/Extensions/ListExtensions.cs b/ICD.Common.Utils/Extensions/ListExtensions.cs index e03b053..dd41884 100644 --- a/ICD.Common.Utils/Extensions/ListExtensions.cs +++ b/ICD.Common.Utils/Extensions/ListExtensions.cs @@ -323,6 +323,28 @@ namespace ICD.Common.Utils.Extensions return extends.BinarySearch(item, comparer) >= 0; } + /// + /// Returns true if the sorted list contains the given item. + /// + /// + /// + /// + /// + /// + [PublicAPI] + public static bool ContainsSorted([NotNull] this IList extends, T item, + [NotNull] Func predicate) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + if (predicate == null) + throw new ArgumentNullException("predicate"); + + PredicateComparer comparer = new PredicateComparer(predicate); + return extends.ContainsSorted(item, comparer); + } + #endregion #region Binary Search