| OLD | NEW |
| 1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 part of quiver.iterables; | 15 part of quiver.iterables; |
| 16 | 16 |
| 17 /** | 17 /// Returns an [Iterable] sequence of [num]s. |
| 18 * Returns an [Iterable] sequence of [num]s. | 18 /// |
| 19 * | 19 /// If only one argument is provided, [start_or_stop] is the upper bound for |
| 20 * If only one argument is provided, [start_or_stop] is the upper bound for the | 20 /// the sequence. If two or more arguments are provided, [stop] is the upper |
| 21 * sequence. If two or more arguments are provided, [stop] is the upper bound. | 21 /// bound. |
| 22 * | 22 /// |
| 23 * The sequence starts at 0 if one argument is provided, or [start_or_stop] if | 23 /// The sequence starts at 0 if one argument is provided, or [start_or_stop] if |
| 24 * two or more arguments are provided. The sequence increments by 1, or [step] | 24 /// two or more arguments are provided. The sequence increments by 1, or [step] |
| 25 * if provided. [step] can be negative, in which case the sequence counts down | 25 /// if provided. [step] can be negative, in which case the sequence counts down |
| 26 * from the starting point and [stop] must be less than the starting point so | 26 /// from the starting point and [stop] must be less than the starting point so |
| 27 * that it becomes the lower bound. | 27 /// that it becomes the lower bound. |
| 28 */ | |
| 29 Iterable<num> range(num start_or_stop, [num stop, num step]) => | 28 Iterable<num> range(num start_or_stop, [num stop, num step]) => |
| 30 new _Range(start_or_stop, stop, step); | 29 new _Range(start_or_stop, stop, step); |
| 31 | 30 |
| 32 class _Range extends IterableBase<num> { | 31 class _Range extends IterableBase<num> { |
| 33 final num start, stop, step; | 32 final num start, stop, step; |
| 34 | 33 |
| 35 _Range(num start_or_stop, num _stop, num _step) | 34 _Range(num start_or_stop, num _stop, num _step) |
| 36 : start = (_stop == null) ? 0 : start_or_stop, | 35 : start = (_stop == null) ? 0 : start_or_stop, |
| 37 stop = (_stop == null) ? start_or_stop : _stop, | 36 stop = (_stop == null) ? start_or_stop : _stop, |
| 38 step = (_step == null) ? 1 : _step { | 37 step = (_step == null) ? 1 : _step { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 65 _inRange = false; | 64 _inRange = false; |
| 66 | 65 |
| 67 num get current => _inRange ? _value : null; | 66 num get current => _inRange ? _value : null; |
| 68 | 67 |
| 69 bool moveNext() { | 68 bool moveNext() { |
| 70 if (_hasNext && _inRange) _value += _step; | 69 if (_hasNext && _inRange) _value += _step; |
| 71 _inRange = _hasNext = (_step > 0) ? (_value < _stop) : (_value > _stop); | 70 _inRange = _hasNext = (_step > 0) ? (_value < _stop) : (_value > _stop); |
| 72 return _hasNext; | 71 return _hasNext; |
| 73 } | 72 } |
| 74 } | 73 } |
| OLD | NEW |