예제 #1
0
        public static bool EnumeratorTest(byte[] a, byte[] b)
        {
            int sum        = 0;
            var enumerator = Enumerator <byte> .Create(a);

            while (enumerator.Next())
            {
                sum += enumerator.Value;
            }

            OnNotify("aa", sum);

            sum = 0;
            var enumeratorA = Enumerator <byte> .Create(a);

            var enumeratorB = Enumerator <byte> .Create(b);

            var enumeratorC = enumeratorA.Concat(enumeratorB);

            while (enumeratorC.Next())
            {
                sum += enumeratorC.Value;
            }
            OnNotify("aa", sum);

            return(true);
        }
예제 #2
0
        public static Enumerator <int> TestIntEnumerator()
        {
            var enumerator = Enumerator <int> .Create(new int[3] {
                4, 6, 8
            });

            return(enumerator);
        }
예제 #3
0
        public void EnumerableFromEnumerator()
        {
            IEnumerable <DateTime> enumerable = EnumerableEx.Create(() => Enumerator.Create(
                                                                        DateTime.Now,
                                                                        DateTime.Now,
                                                                        DateTime.Now,
                                                                        DateTime.Now,
                                                                        DateTime.Now));

            _consumer.Consume(enumerable);
        }
예제 #4
0
        public static int TestNext(byte[] a)
        {
            int sum        = 0;
            var enumerator = Enumerator <byte> .Create(a);

            while (enumerator.Next())
            {
                sum += enumerator.Value;
            }

            return(sum);
        }
예제 #5
0
        public static int TestNextIntArray(int[] a)
        {
            int sum        = 0;
            var enumerator = Enumerator <int> .Create(a);

            while (enumerator.Next())
            {
                sum += enumerator.Value;
            }

            return(sum);
        }
예제 #6
0
        public static int TestConcat(byte[] a, byte[] b)
        {
            int sum         = 0;
            var enumeratorA = Enumerator <byte> .Create(a);

            var enumeratorB = Enumerator <byte> .Create(b);

            var enumeratorC = enumeratorA.Concat(enumeratorB);

            while (enumeratorC.Next())
            {
                sum += enumeratorC.Value;
            }

            return(sum);
        }
예제 #7
0
 public IEnumerator <Layer> GetEnumerator()
 {
     return(Enumerator.Create(layers));
 }
예제 #8
0
        public static async Tasks.Task <Generic.IEnumerator <T> > WhenAll <T>(this Generic.IEnumerator <Tasks.Task <T> > me)
        {
            var current = await me.Next();

            return(current.IsNull() ? Enumerator.Create(current) : (await me.WhenAll()).Prepend(current));
        }
예제 #9
0
 public static Generic.IEnumerator <Tasks.Task <T> > FilterTasks <T>(this Generic.IEnumerator <Tasks.Task <T> > me, Func <T, bool> predicate)
 {
     return(Enumerator.Create(() => me.FilterNext(predicate), me.Reset, me.Dispose));
 }
예제 #10
0
 public IEnumerator <object> GetEnumerator() => Enumerator.Create(this);