public void GroupByOverloadDEx() { var _src = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; var r = _src.GroupBy(i => i > 5, FuncHelper.GetIdentityFunc <int>(), (key, group) => StringHelper.Concat(group.ToArray()), null); var _r = r.ToArray(); Assert.AreEqual(_r.Length, 2); Assert.AreEqual(_r[0], "12345"); Assert.AreEqual(_r[1], "678910"); }
public void GroupProgressiveByOverloadDEx() { var src = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; var r = src.GroupProgressiveBy(i => i > 5, FuncHelper.GetIdentityFunc <int>(), (_, group) => StringEx.Concat(group.ToArray()), null); var rArray = r.ToArray(); Assert.AreEqual(rArray.Length, 2); Assert.AreEqual(rArray[0], "12345"); Assert.AreEqual(rArray[1], "678910"); }
public static IEnumerable <TResult> GroupBy <TSource, TKey, TResult>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, Func <TKey, IEnumerable <TSource>, TResult> resultSelector, IEqualityComparer <TKey>?comparer) { return(new GroupedConvertedEnumerable <TSource, TKey, TSource, TResult>(source, keySelector, FuncHelper.GetIdentityFunc <TSource>(), resultSelector, comparer)); }
public static IEnumerable <IGrouping <TKey, TSource> > GroupBy <TSource, TKey>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, IEqualityComparer <TKey>?comparer) { return(new GroupedEnumerable <TSource, TKey, TSource>(source, keySelector, FuncHelper.GetIdentityFunc <TSource>(), comparer)); }
public static ILookup <TKey, TSource> ToLookup <TSource, TKey>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, IEqualityComparer <TKey> comparer) { return(Lookup <TKey, TSource> .Create(source, keySelector, FuncHelper.GetIdentityFunc <TSource>(), comparer)); }
public static ILookup <TKey, TSource> ToLookup <TSource, TKey>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector) { return(Lookup <TKey, TSource> .Create(source, keySelector, FuncHelper.GetIdentityFunc <TSource>(), null)); }
public static Dictionary <TKey, TSource> ToDictionary <TSource, TKey>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, IEqualityComparer <TKey>?comparer) { return(ToDictionary(source, keySelector, FuncHelper.GetIdentityFunc <TSource>(), comparer)); }
public static IEnumerable <IGrouping <TKey, TSource> > GroupProgressiveBy <TSource, TKey>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, IEqualityComparer <TKey> comparer) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (keySelector == null) { throw new ArgumentNullException(nameof(keySelector)); } return(GroupBuilder <TKey, TSource, TSource> .CreateGroups(source, comparer, keySelector, FuncHelper.GetIdentityFunc <TSource>())); }