예제 #1
0
        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");
        }
예제 #2
0
        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");
        }
예제 #3
0
 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));
 }
예제 #4
0
 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));
 }
예제 #5
0
 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));
 }
예제 #6
0
 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));
 }
예제 #7
0
 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));
 }
예제 #8
0
        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>()));
        }