This commit is contained in:
CortexCore
2024-11-03 16:38:17 +08:00
parent 056e2cada5
commit 4ba741408d
4693 changed files with 2445 additions and 5443 deletions

View File

@@ -147,6 +147,21 @@ namespace BITKit
}
}
public static IEnumerable<T> SelectManyPro<T>(this IEnumerable<T> self, Func<T, IEnumerable<T>> factory)
{
return Get(self);
IEnumerable<T> Get(IEnumerable<T> list)
{
var newList = new List<T>();
foreach (var x in list)
{
newList.Add(x);
newList.AddRange(Get(factory.Invoke(x)));
}
return newList.Distinct();
}
}
/// <summary>
/// 获取集合中所有的组合,每个组合中的元素个数为输入集合的元素个数,每个元素只出现一次
/// </summary>