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

Unified Diff: sdk/lib/_collection_dev/list.dart

Issue 12207205: Revert "Remove deprecated mappedBy." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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_dev/iterable.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/js_array.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_collection_dev/list.dart
diff --git a/sdk/lib/_collection_dev/list.dart b/sdk/lib/_collection_dev/list.dart
index d7b2661fd4da14d9ac4b5f7230698ffdd638f168..0260290dc1dd423987a17037d675354d6c6f9024 100644
--- a/sdk/lib/_collection_dev/list.dart
+++ b/sdk/lib/_collection_dev/list.dart
@@ -97,6 +97,10 @@ abstract class ListBase<E> extends Collection<E> implements List<E> {
return new MappedIterable(this, f);
}
+ List mappedBy(f(E element)) {
+ return new MappedList(this, f);
+ }
+
Iterable<E> take(int n) {
return new SubListIterable(this, 0, n);
}
@@ -282,6 +286,16 @@ abstract class UnmodifiableListBase<E> extends ListBase<E> {
}
}
+class MappedList<S, T> extends UnmodifiableListBase<T> {
+ final List<S> _list;
+ // TODO(ahe): Restore type when feature is implemented in dart2js
+ // checked mode. http://dartbug.com/7733
+ final /* _Transformation<S, T> */ _f;
+
+ MappedList(this._list, T this._f(S element));
+
+ T operator[](int index) => _f(_list[index]);
+ int get length => _list.length;
}
/** An empty fixed-length list. */
« no previous file with comments | « sdk/lib/_collection_dev/iterable.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/js_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698