| Index: sdk/lib/core/list.dart
|
| diff --git a/sdk/lib/core/list.dart b/sdk/lib/core/list.dart
|
| index 997b2c3f31ad09afcfa93a96a6975b1857ae5cfc..82e60a16930abc3dcc9cddcf5e18082f03a055a4 100644
|
| --- a/sdk/lib/core/list.dart
|
| +++ b/sdk/lib/core/list.dart
|
| @@ -118,6 +118,38 @@ abstract class List<E> implements Iterable<E>, EfficientLength {
|
| }
|
|
|
| /**
|
| + * Create a list of values between `from` and `to`.
|
| + *
|
| + * The list starts with `from` as the first value, and then
|
| + * progresses towards `to` in increments of `step`, and stops when reaching
|
| + * or overshooting `to`. If it hits `to` the `to` value is included,
|
| + * otherwise it isn't.
|
| + *
|
| + * If `to` is less than `from`, the values are in decreasing order.
|
| + *
|
| + * The [step] value must always be positive. It defaults to `1`.
|
| + *
|
| + * If [growable] is true, the resulting list is growable, otherwise
|
| + * it defaults to a fixed-length list.
|
| + */
|
| + static List<int> range(int from, int to, {int step: 1, growable: false}) {
|
| + if (step <= 0) {
|
| + throw new RangeError.value("Step must be positive, was $step");
|
| + }
|
| + final int delta = to - from;
|
| + if (delta < 0) {
|
| + step = -step;
|
| + }
|
| + final int steps = delta ~/ step + 1;
|
| + List list = growable ? new List<int>()..length = steps
|
| + : new List<int>(steps);
|
| + for (int i = 0; i < steps; i++) {
|
| + list[i] = from + i * step;
|
| + }
|
| + return list;
|
| + }
|
| +
|
| + /**
|
| * Returns the object at the given [index] in the list
|
| * or throws a [RangeError] if [index] is out of bounds.
|
| */
|
|
|