Chromium Code Reviews| 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 |
| /** |