示例#1
0
            public override T TryGetNext(out bool success)
            {
                switch (_state)
                {
                case 1:
                    _enumerator = _source.GetEnumerator();
                    _state      = 2;
                    goto case 2;

                case 2:
                    while (true)
                    {
                        var item = _enumerator.TryGetNext(out success);
                        if (!success)
                        {
                            break;
                        }

                        if (_predicate(item))
                        {
                            return(item);
                        }
                    }
                    break;
                }

                success = false;
                return(default(T));
            }
示例#2
0
        public long IFastEnumerator()
        {
            IFastEnumerator <int> ife = _array.GetFastEnumerator();
            long total     = 0;
            bool remaining = true;

            ife.Reset();
loop:
            var i = ife.TryGetNext(out remaining);

            if (remaining)
            {
                total += i;
                goto loop;
            }
            return(total);
        }
示例#3
0
            public override R TryGetNext(out bool success)
            {
                switch (_state)
                {
                case 1:
                    _enumerator = _source.GetEnumerator();
                    _state      = 2;
                    goto case 2;

                case 2:
                    var item = _enumerator.TryGetNext(out success);
                    if (success)
                    {
                        return(_selector(item));
                    }
                    break;
                }

                success = false;
                return(default(R));
            }