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

Unified Diff: sdk/lib/collection/collections.dart

Issue 11971016: Create IterableMixinWorkaround and move most of the Collections methods there. (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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/js_array.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/collections.dart
diff --git a/sdk/lib/collection/collections.dart b/sdk/lib/collection/collections.dart
index 4bd1fadb513ce5e84a36fbb51ae347e2db93af69..146385b4ce9b757762511d69c7350e6209beb274 100644
--- a/sdk/lib/collection/collections.dart
+++ b/sdk/lib/collection/collections.dart
@@ -4,12 +4,7 @@
part of dart.collection;
Lasse Reichstein Nielsen 2013/01/16 15:34:31 Add comment describing purpose of class.
floitsch 2013/01/16 16:11:35 Done.
-/**
- * The [Collections] class implements static methods useful when
- * writing a class that implements [Collection] and the [iterator]
- * method.
- */
-class Collections {
+class IterableMixinWorkaround {
static bool contains(Iterable iterable, var element) {
for (final e in iterable) {
if (element == e) return true;
@@ -204,6 +199,41 @@ class Collections {
return buffer.toString();
}
+ static Iterable where(Iterable<Object> iterable, bool f(var element)) {
+ return new WhereIterable(iterable, f);
Lasse Reichstein Nielsen 2013/01/16 15:34:31 Just make the first argument be type "Iterable" wi
floitsch 2013/01/16 16:11:35 Done.
+ }
+
+ static List mappedByList(List<Object> list, f(var element)) {
+ return new MappedList(list, f);
+ }
+
+ static List takeList(List<Object> list, int n) {
+ // TODO(floitsch): missing generic type.
Lasse Reichstein Nielsen 2013/01/16 15:34:31 It's a workaround, it'll be fixed when we have mix
floitsch 2013/01/16 16:11:35 Replaced with normal comment.
+ return new ListView(list, 0, n);
+ }
+
+ static Iterable takeWhile(Iterable iterable, bool test(var value)) {
+ // TODO(floitsch): missing generic type.
+ return new TakeWhileIterable(iterable, test);
+ }
+
+ static List skipList(List<Object> list, int n) {
+ // TODO(floitsch): missing generic type.
+ return new ListView(list, n, null);
+ }
+
+ static Iterable skipWhile(Iterable iterable, bool test(var value)) {
+ // TODO(floitsch): missing generic type.
+ return new SkipWhileIterable(iterable, test);
+ }
+}
+
+/**
+ * The [Collections] class implements static methods useful when
+ * writing a class that implements [Collection] and the [iterator]
+ * method.
+ */
+class Collections {
// TODO(jjb): visiting list should be an identityHashSet when it exists
/**
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/js_array.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698