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

Unified Diff: sdk/lib/core/iterable.dart

Issue 26681002: Add EfficientLength marker interface to some iterabels. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also document Map.length is efficient, while we are at it. Created 7 years, 2 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
« no previous file with comments | « sdk/lib/collection/splay_tree.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/iterable.dart
diff --git a/sdk/lib/core/iterable.dart b/sdk/lib/core/iterable.dart
index 0e1f05a123f0839573de7176c7bf1eca331a681c..42ecd46652decb7d73fd399d9ac41332770d25e3 100644
--- a/sdk/lib/core/iterable.dart
+++ b/sdk/lib/core/iterable.dart
@@ -201,7 +201,7 @@ abstract class Iterable<E> {
/**
* Returns an Iterable that skips the first [n] elements.
*
- * If `this` has fewer than [n] elements, then the resulting Iterable is
+ * If `this` has fewer than [n] elements, then the resulting Iterable is
* empty.
*
* It is an error if [n] is negative.
@@ -280,14 +280,15 @@ abstract class Iterable<E> {
E elementAt(int index);
}
-
typedef E _Generator<E>(int index);
-class _GeneratorIterable<E> extends IterableBase<E> {
+class _GeneratorIterable<E> extends IterableBase<E>
+ implements EfficientLength {
final int _count;
final _Generator<E> _generator;
_GeneratorIterable(this._count, this._generator);
Iterator<E> get iterator => new _GeneratorIterator(_count, _generator);
+ int get length => _count;
}
class _GeneratorIterator<E> implements Iterator<E> {
« no previous file with comments | « sdk/lib/collection/splay_tree.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698