Chromium Code Reviews| Index: sdk/lib/core/iterable.dart |
| diff --git a/sdk/lib/core/iterable.dart b/sdk/lib/core/iterable.dart |
| index 603a9df1a1e5ef04a740d127c4dcb83b6f97685b..538720d1399e8f1cbf4d0a12c608ca9deb4d7264 100644 |
| --- a/sdk/lib/core/iterable.dart |
| +++ b/sdk/lib/core/iterable.dart |
| @@ -15,6 +15,8 @@ |
| * be used as the right-hand side of a for-in construct. |
| */ |
| abstract class Iterable<E> { |
| + const Iterable(); |
| + |
| /** |
| * Returns an [Iterator] that iterates over this [Iterable] object. |
| */ |
| @@ -28,7 +30,13 @@ abstract class Iterable<E> { |
| * to return a collection of the same general type as themselves. |
| * E.g., [List.mappedBy] should return a [List]. |
| */ |
| - Collection mappedBy(f(E element)); |
| + Collection mappedBy(f(E element)) { |
| + // TODO(floitsch): this is just a temporary function to provide a complete |
| + // skeleton. It will be changed to become lazy soon. |
|
sra1
2012/11/15 01:02:18
How will it be lazy?
floitsch
2012/11/15 01:27:27
Have a look here:
https://chromiumcodereview.appsp
|
| + List result = new List(); |
|
sra1
2012/11/15 01:02:18
Any reason to use new List() when the more concise
floitsch
2012/11/15 01:27:27
Done.
|
| + for (E element in this) result.add(f(element)); |
| + return result; |
| + } |
| /** |
| * Returns a collection with the elements of this collection |
| @@ -40,7 +48,13 @@ abstract class Iterable<E> { |
| * An element satisfies the predicate [f] if [:f(element):] |
| * returns true. |
| */ |
| - Collection<E> where(bool f(E element)); |
| + Collection<E> where(bool f(E element)) { |
| + // TODO(floitsch): this is just a temporary function to provide a complete |
| + // skeleton. It will be changed to become lazy soon. |
| + List result = new List<E>(); |
|
sra1
2012/11/15 01:02:18
Ditto <E>[]
floitsch
2012/11/15 01:27:27
Done.
|
| + for (E element in this) if (f(element)) result.add(element); |
| + return result; |
| + } |
| /** |
| * Check whether the collection contains an element equal to [element]. |