示例#1
0
        void ForceChunk()
        {
            if (_chunk != null)
            {
                return;
            }

            Object[] arr = new Object[CHUNK_SIZE];
            int      n   = 0;
            Object   val = _start;

            while (n < CHUNK_SIZE)
            {
                arr[n++] = val;
                val      = Numbers.addP(val, _step);
                if (_boundsCheck.ExceededBounds(val))
                {
                    //partial last chunk
                    _chunk = new ArrayChunk(arr, 0, n);
                    return;
                }
            }

            // full last chunk
            if (_boundsCheck.ExceededBounds(val))
            {
                _chunk = new ArrayChunk(arr, 0, CHUNK_SIZE);
                return;
            }

            // full intermediate chunk
            _chunk     = new ArrayChunk(arr, 0, CHUNK_SIZE);
            _chunkNext = new Range(val, _end, _step, _boundsCheck);
        }
示例#2
0
        public override System.Collections.IEnumerator GetEnumerator()
        {
            object next = this._start;

            while (!_boundsCheck.ExceededBounds(next))
            {
                yield return(next);

                try
                {
                    next = Numbers.Add(next, this._step);
                }
                catch (ArithmeticException) { yield break; }
            }
        }