Exemplo n.º 1
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>()));
 }
Exemplo n.º 2
0
        public override IList <IEnumerator <T> > GetPartitions(int partitionCount)
        {
            var index  = -1;
            var groups = GroupBuilder <int, T, T> .CreateGroups
                         (
                _source,
                EqualityComparer <int> .Default,
                arg => Interlocked.Increment(ref index) % partitionCount,
                obj => obj
                         );

            return(Extensions.WrapAsIList(groups.ConvertProgressive(g => g.GetEnumerator())));
        }
Exemplo n.º 3
0
        public static IEnumerable <IGrouping <TKey, TElement> > GroupProgressiveBy <TSource, TKey, TElement>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TElement> resultSelector, IEqualityComparer <TKey>?comparer)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (keySelector == null)
            {
                throw new ArgumentNullException(nameof(keySelector));
            }

            if (resultSelector == null)
            {
                throw new ArgumentNullException(nameof(resultSelector));
            }

            return(GroupBuilder <TKey, TSource, TElement> .CreateGroups(source, comparer ?? EqualityComparer <TKey> .Default, keySelector, resultSelector));
        }