| Index: sdk/lib/internal/iterable.dart
|
| diff --git a/sdk/lib/internal/iterable.dart b/sdk/lib/internal/iterable.dart
|
| index 4cf841801a840490b88d5501340bac09ba45282f..006b31acb6fef4ee6860799d8135c2c10c6b1cfe 100644
|
| --- a/sdk/lib/internal/iterable.dart
|
| +++ b/sdk/lib/internal/iterable.dart
|
| @@ -195,11 +195,11 @@ abstract class ListIterable<E> extends IterableBase<E>
|
| return value;
|
| }
|
|
|
| - Iterable<E> skip(int count) => new SubListIterable(this, count, null);
|
| + Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null);
|
|
|
| Iterable<E> skipWhile(bool test(E element)) => super.skipWhile(test);
|
|
|
| - Iterable<E> take(int count) => new SubListIterable(this, 0, count);
|
| + Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count);
|
|
|
| Iterable<E> takeWhile(bool test(E element)) => super.takeWhile(test);
|
|
|
| @@ -276,17 +276,21 @@ class SubListIterable<E> extends ListIterable<E> {
|
|
|
| Iterable<E> skip(int count) {
|
| if (count < 0) throw new RangeError.value(count);
|
| - return new SubListIterable(_iterable, _start + count, _endOrLength);
|
| + int newStart = _start + count;
|
| + if (_endOrLength != null && newStart >= _endOrLength) {
|
| + return new EmptyIterable<E>();
|
| + }
|
| + return new SubListIterable<E>(_iterable, newStart, _endOrLength);
|
| }
|
|
|
| Iterable<E> take(int count) {
|
| if (count < 0) throw new RangeError.value(count);
|
| if (_endOrLength == null) {
|
| - return new SubListIterable(_iterable, _start, _start + count);
|
| + return new SubListIterable<E>(_iterable, _start, _start + count);
|
| } else {
|
| int newEnd = _start + count;
|
| if (_endOrLength < newEnd) return this;
|
| - return new SubListIterable(_iterable, _start, newEnd);
|
| + return new SubListIterable<E>(_iterable, _start, newEnd);
|
| }
|
| }
|
| }
|
| @@ -740,7 +744,7 @@ abstract class BidirectionalIterator<T> implements Iterator<T> {
|
| *
|
| * The uses of this class will be replaced by mixins.
|
| */
|
| -class IterableMixinWorkaround {
|
| +class IterableMixinWorkaround<T> {
|
| static bool contains(Iterable iterable, var element) {
|
| for (final e in iterable) {
|
| if (e == element) return true;
|
| @@ -934,8 +938,8 @@ class IterableMixinWorkaround {
|
| return buffer.toString();
|
| }
|
|
|
| - static Iterable where(Iterable iterable, bool f(var element)) {
|
| - return new WhereIterable(iterable, f);
|
| + Iterable<T> where(Iterable iterable, bool f(var element)) {
|
| + return new WhereIterable<T>(iterable, f);
|
| }
|
|
|
| static Iterable map(Iterable iterable, f(var element)) {
|
| @@ -950,28 +954,28 @@ class IterableMixinWorkaround {
|
| return new ExpandIterable(iterable, f);
|
| }
|
|
|
| - static Iterable takeList(List list, int n) {
|
| + Iterable<T> takeList(List list, int n) {
|
| // The generic type is currently lost. It will be fixed with mixins.
|
| - return new SubListIterable(list, 0, n);
|
| + return new SubListIterable<T>(list, 0, n);
|
| }
|
|
|
| - static Iterable takeWhile(Iterable iterable, bool test(var value)) {
|
| + Iterable<T> takeWhile(Iterable iterable, bool test(var value)) {
|
| // The generic type is currently lost. It will be fixed with mixins.
|
| - return new TakeWhileIterable(iterable, test);
|
| + return new TakeWhileIterable<T>(iterable, test);
|
| }
|
|
|
| - static Iterable skipList(List list, int n) {
|
| + Iterable<T> skipList(List list, int n) {
|
| // The generic type is currently lost. It will be fixed with mixins.
|
| - return new SubListIterable(list, n, null);
|
| + return new SubListIterable<T>(list, n, null);
|
| }
|
|
|
| - static Iterable skipWhile(Iterable iterable, bool test(var value)) {
|
| + Iterable<T> skipWhile(Iterable iterable, bool test(var value)) {
|
| // The generic type is currently lost. It will be fixed with mixins.
|
| - return new SkipWhileIterable(iterable, test);
|
| + return new SkipWhileIterable<T>(iterable, test);
|
| }
|
|
|
| - static Iterable reversedList(List list) {
|
| - return new ReversedListIterable(list);
|
| + Iterable<T> reversedList(List list) {
|
| + return new ReversedListIterable<T>(list);
|
| }
|
|
|
| static void sortList(List list, int compare(a, b)) {
|
| @@ -1009,10 +1013,10 @@ class IterableMixinWorkaround {
|
| }
|
| }
|
|
|
| - static Iterable getRangeList(List list, int start, int end) {
|
| + Iterable<T> getRangeList(List list, int start, int end) {
|
| _rangeCheck(list, start, end);
|
| // The generic type is currently lost. It will be fixed with mixins.
|
| - return new SubListIterable(list, start, end);
|
| + return new SubListIterable<T>(list, start, end);
|
| }
|
|
|
| static void setRangeList(List list, int start, int end,
|
| @@ -1097,8 +1101,8 @@ class IterableMixinWorkaround {
|
| }
|
| }
|
|
|
| - static Map<int, dynamic> asMapList(List l) {
|
| - return new ListMapView(l);
|
| + Map<int, T> asMapList(List l) {
|
| + return new ListMapView<T>(l);
|
| }
|
|
|
| static bool setContainsAll(Set set, Iterable other) {
|
|
|