Chromium Code Reviews| Index: lib/src/iterable_zip.dart |
| diff --git a/lib/src/iterable_zip.dart b/lib/src/iterable_zip.dart |
| index 30acb0e72477600b6e44c5fc4dad522a37dc3c38..77ae6139aace56f5907eb8ffd88d28e092a458e7 100644 |
| --- a/lib/src/iterable_zip.dart |
| +++ b/lib/src/iterable_zip.dart |
| @@ -2,7 +2,7 @@ |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| -import "dart:collection"; |
| +import "dart:collection" show IterableBase; |
|
nweiz
2016/03/21 20:09:18
Generally we don't use show/hide with import unles
|
| /// Iterable that iterates over lists of values from other iterables. |
| /// |
| @@ -13,24 +13,27 @@ import "dart:collection"; |
| /// combined into a single list, which becomes the next value of this |
| /// [Iterable]'s [Iterator]. As soon as any of the iterators run out, |
| /// the zipped iterator also stops. |
| -class IterableZip extends IterableBase<List> { |
| - final Iterable<Iterable> _iterables; |
| - IterableZip(Iterable<Iterable> iterables) |
| +class IterableZip<T> extends IterableBase<List<T>> { |
| + final Iterable<Iterable<T>> _iterables; |
| + |
| + IterableZip(Iterable<Iterable<T>> iterables) |
| : this._iterables = iterables; |
| /// Returns an iterator that combines values of the iterables' iterators |
| /// as long as they all have values. |
| - Iterator<List> get iterator { |
| - List iterators = _iterables.map((x) => x.iterator).toList(growable: false); |
| + Iterator<List<T>> get iterator { |
| + var iterators = _iterables.map((x) => x.iterator).toList(growable: false); |
| // TODO(lrn): Return an empty iterator directly if iterators is empty? |
| - return new _IteratorZip(iterators); |
| + return new _IteratorZip<T>(iterators); |
| } |
| } |
| -class _IteratorZip implements Iterator<List> { |
| - final List<Iterator> _iterators; |
| - List _current; |
| - _IteratorZip(List iterators) : _iterators = iterators; |
| +class _IteratorZip<T> implements Iterator<List<T>> { |
| + final List<Iterator<T>> _iterators; |
| + List<T> _current; |
| + |
| + _IteratorZip(List<Iterator<T>> iterators) : _iterators = iterators; |
| + |
| bool moveNext() { |
| if (_iterators.isEmpty) return false; |
| for (int i = 0; i < _iterators.length; i++) { |
| @@ -46,5 +49,5 @@ class _IteratorZip implements Iterator<List> { |
| return true; |
| } |
| - List get current => _current; |
| + List<T> get current => _current; |
| } |