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

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

Issue 12041045: List.mappedBy/skip/take returns a List. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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: sdk/lib/core/list.dart
diff --git a/sdk/lib/core/list.dart b/sdk/lib/core/list.dart
index fa1b9aafa4bc86fbb10acbade95f18457e3e75b0..fa6c66936698150be268db355b46b099d94619aa 100644
--- a/sdk/lib/core/list.dart
+++ b/sdk/lib/core/list.dart
@@ -198,4 +198,34 @@ abstract class List<E> implements Collection<E> {
* [start] is greater than the length of the list.
*/
void insertRange(int start, int length, [E fill]);
+
+ /**
+ * Returns a lazy [List] where each element [:e:] of [this] is replaced
+ * by the result of [:f(e):].
Lasse Reichstein Nielsen 2013/01/24 06:49:32 Mention "unmodifiable" somewhere.
floitsch 2013/01/24 13:48:34 Done.
+ *
+ * This method returns a view of the mapped elements. As long as the
+ * returned [List] is not indexed or iterated over, the supplied function [f]
+ * will not be invoked. The transformed elements will not be cached. Accessing
+ * elements multiple times will invoke the supplied function [f] multiple
+ * times.
+ */
+ List mappedBy(f(E element));
+
+ /**
+ * Returns a [List] that hides the first [n] elements. The returned
Lasse Reichstein Nielsen 2013/01/24 06:49:32 Newlines after '.'.
floitsch 2013/01/24 13:48:34 Done.
+ * list is a view backed by [this].
Lasse Reichstein Nielsen 2013/01/24 06:49:32 [this] -> [:this:]. It's not a declared name.
floitsch 2013/01/24 13:48:34 Done.
+ *
+ * If [this] has fewer than [n] elements, then the resulting [Iterable] will
Lasse Reichstein Nielsen 2013/01/24 06:49:32 If -> While. It can change if the underlying list
floitsch 2013/01/24 13:48:34 Done.
+ * be empty.
+ */
+ List<E> skip(int n);
+
+ /**
+ * Returns a [List] with at most [n] elements. The returned list is a view
+ * backed by this.
Lasse Reichstein Nielsen 2013/01/24 06:49:32 this -> [:this:] (or "this [List]").
floitsch 2013/01/24 13:48:34 Done.
+ *
+ * The returned [List] may contain fewer than [n] elements, if [this]
+ * contains fewer than [n] elements.
+ */
+ List<E> take(int n);
}

Powered by Google App Engine
This is Rietveld 408576698