Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Unified Diff: lib/src/iterable_zip.dart

Issue 1817463002: Finish @nex3's strong-mode fixes in package:collection and test it in Travis (Closed) Base URL: https://github.com/ochafik/collection.git@master
Patch Set: revert _throw (now generic) Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698