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

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

Issue 2467113003: Make EfficientLength extend Iterable. (Closed)
Patch Set: Reverted, prepare to reland. Make new test not break web-testing framework. Created 4 years, 1 month 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/core/set.dart ('k') | tests/corelib/growable_list_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/internal/iterable.dart
diff --git a/sdk/lib/internal/iterable.dart b/sdk/lib/internal/iterable.dart
index 0e7b171e26002c4aa73f57516a1b7246196dee82..73b3669f5fc84facba92303c9b344cafd9a58313 100644
--- a/sdk/lib/internal/iterable.dart
+++ b/sdk/lib/internal/iterable.dart
@@ -8,7 +8,8 @@ part of dart._internal;
* Marker interface for [Iterable] subclasses that have an efficient
* [length] implementation.
*/
-abstract class EfficientLength {
+abstract class EfficientLengthIterable<T> extends Iterable<T> {
+ const EfficientLengthIterable();
/**
* Returns the number of elements in the iterable.
*
@@ -24,8 +25,7 @@ abstract class EfficientLength {
* All other methods are implemented in terms of [length] and [elementAt],
* including [iterator].
*/
-abstract class ListIterable<E> extends Iterable<E>
- implements EfficientLength {
+abstract class ListIterable<E> extends EfficientLengthIterable<E> {
int get length;
E elementAt(int i);
@@ -354,7 +354,7 @@ class MappedIterable<S, T> extends Iterable<T> {
final _Transformation<S, T> _f;
factory MappedIterable(Iterable<S> iterable, T function(S value)) {
- if (iterable is EfficientLength) {
+ if (iterable is EfficientLengthIterable) {
return new EfficientLengthMappedIterable<S, T>(iterable, function);
}
return new MappedIterable<S, T>._(iterable, function);
@@ -376,7 +376,7 @@ class MappedIterable<S, T> extends Iterable<T> {
}
class EfficientLengthMappedIterable<S, T> extends MappedIterable<S, T>
- implements EfficientLength {
+ implements EfficientLengthIterable<T> {
EfficientLengthMappedIterable(Iterable<S> iterable, T function(S value))
: super._(iterable, function);
}
@@ -406,7 +406,7 @@ class MappedIterator<S, T> extends Iterator<T> {
* Expects efficient `length` and `elementAt` on the source iterable.
*/
class MappedListIterable<S, T> extends ListIterable<T>
- implements EfficientLength {
+ implements EfficientLengthIterable<T> {
final Iterable<S> _source;
final _Transformation<S, T> _f;
@@ -427,7 +427,7 @@ class WhereIterable<E> extends Iterable<E> {
Iterator<E> get iterator => new WhereIterator<E>(_iterable.iterator, _f);
- // Specialization of [Iterable.map] to non-EfficientLength.
+ // Specialization of [Iterable.map] to non-EfficientLengthIterable.
Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E element)) =>
new MappedIterable<E, dynamic/*=T*/>._(this, f);
}
@@ -500,7 +500,7 @@ class TakeIterable<E> extends Iterable<E> {
if (takeCount is! int || takeCount < 0) {
throw new ArgumentError(takeCount);
}
- if (iterable is EfficientLength) {
+ if (iterable is EfficientLengthIterable) {
return new EfficientLengthTakeIterable<E>(iterable, takeCount);
}
return new TakeIterable<E>._(iterable, takeCount);
@@ -514,7 +514,7 @@ class TakeIterable<E> extends Iterable<E> {
}
class EfficientLengthTakeIterable<E> extends TakeIterable<E>
- implements EfficientLength {
+ implements EfficientLengthIterable<E> {
EfficientLengthTakeIterable(Iterable<E> iterable, int takeCount)
: super._(iterable, takeCount);
@@ -587,7 +587,7 @@ class SkipIterable<E> extends Iterable<E> {
final int _skipCount;
factory SkipIterable(Iterable<E> iterable, int count) {
- if (iterable is EfficientLength) {
+ if (iterable is EfficientLengthIterable) {
return new EfficientLengthSkipIterable<E>(iterable, count);
}
return new SkipIterable<E>._(iterable, count);
@@ -614,7 +614,7 @@ class SkipIterable<E> extends Iterable<E> {
}
class EfficientLengthSkipIterable<E> extends SkipIterable<E>
- implements EfficientLength {
+ implements EfficientLengthIterable<E> {
EfficientLengthSkipIterable(Iterable<E> iterable, int skipCount)
: super._(iterable, skipCount);
@@ -676,7 +676,7 @@ class SkipWhileIterator<E> extends Iterator<E> {
/**
* The always empty [Iterable].
*/
-class EmptyIterable<E> extends Iterable<E> implements EfficientLength {
+class EmptyIterable<E> extends EfficientLengthIterable<E> {
const EmptyIterable();
Iterator<E> get iterator => const EmptyIterator();
« no previous file with comments | « sdk/lib/core/set.dart ('k') | tests/corelib/growable_list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698