This commit is contained in:
CortexCore
2023-10-02 23:24:56 +08:00
parent 8ef5c7ec0a
commit 947e52e748
183 changed files with 107857 additions and 9378 deletions

View File

@@ -44,6 +44,19 @@ namespace BITKit
return list;
}
public static bool TryGetIndexOf<T>(this IEnumerable<T> self, Func<T, bool> factory, out int index)
{
index = -1;
var enumerable = self as T[] ?? self.ToArray();
for (var i = 0; i < enumerable.Length; i++)
{
var item = enumerable.ElementAt(i);
if (!factory.Invoke(item)) continue;
index = i;
return true;
}
return false;
}
public static bool Contains<T>(IEnumerable<T> a, IEnumerable<T> b)
{
foreach (var x in b)