Example #1
0
 public override IEnumerable <T> GetDynamicPartitions()
 {
     if (_source is T[] array)
     {
         return(Progressor <T> .CreateFromArray(array));
     }
     if (_source is IList <T> list)
     {
         return(Progressor <T> .CreateFromIList(list));
     }
     return(Progressor <T> .CreateFromIEnumerable(_source));
 }
        public override IList <IEnumerator <T> > GetPartitions(int partitionCount)
        {
            var list   = new List <IEnumerator <T> >(partitionCount);
            var source = Progressor <T> .CreateFromIEnumerable(_source);

            for (var index = 0; index < partitionCount; index++)
            {
                list.Add(Enumerator());
            }

            return(list.AsReadOnly());

            IEnumerator <T> Enumerator()
            {
                foreach (var item in source)
                {
                    yield return(item);
                }
            }
        }
        public override IList <IEnumerator <KeyValuePair <long, T> > > GetOrderablePartitions(int partitionCount)
        {
            var list   = new List <IEnumerator <KeyValuePair <long, T> > >(partitionCount);
            var source = Progressor <T> .CreateFromIEnumerable(_source);

            for (var index = 0; index < partitionCount; index++)
            {
                list.Add(Enumerator(index));
            }

            return(list.AsReadOnly());

            IEnumerator <KeyValuePair <long, T> > Enumerator(int index)
            {
                var subIndex = 0;

                foreach (var item in source)
                {
                    yield return(new KeyValuePair <long, T>(NumericHelper.BuildInt64(index, subIndex), item));

                    subIndex++;
                }
            }
        }
 public override IEnumerable <T> GetDynamicPartitions()
 {
     return(Progressor <T> .CreateFromIEnumerable(_source));
 }