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

Side by Side Diff: corelib/src/collection.dart

Issue 9114021: Added method map to Collection interface and all its implementations (except classes generated fr... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * The [Collection] interface is the public interface of all 6 * The [Collection] interface is the public interface of all
7 * collections. 7 * collections.
8 */ 8 */
9 interface Collection<E> extends Iterable<E> { 9 interface Collection<E> extends Iterable<E> {
10 /** 10 /**
11 * Applies the function [f] to each element of this collection. 11 * Applies the function [f] to each element of this collection.
12 */ 12 */
13 void forEach(void f(E element)); 13 void forEach(void f(E element));
14 14
15 /** 15 /**
16 * Returns a new collection with the elements [: f(e) :]
17 * for each element [e] of this collection.
18 *
19 * Note on typing: the return type of f() could be an arbitrary
20 * type R and consequently the returned collection's
21 * type would be Collection<R>.
ahe 2012/01/05 22:36:54 This comment is confusing. The static type may con
Ivan Posva 2012/01/05 22:47:03 I don't think this comment is entirely correct. Th
22 */
23 Collection map(f(E element));
24
25 /**
16 * Returns a new collection with the elements of this collection 26 * Returns a new collection with the elements of this collection
17 * that satisfy the predicate [f]. 27 * that satisfy the predicate [f].
18 * 28 *
19 * An element satisfies the predicate [f] if [:f(element):] 29 * An element satisfies the predicate [f] if [:f(element):]
20 * returns true. 30 * returns true.
21 */ 31 */
22 Collection<E> filter(bool f(E element)); 32 Collection<E> filter(bool f(E element));
23 33
ahe 2012/01/05 22:36:54 Extra line.
34
24 /** 35 /**
25 * Returns true if every elements of this collection satisify the 36 * Returns true if every elements of this collection satisify the
26 * predicate [f]. Returns false otherwise. 37 * predicate [f]. Returns false otherwise.
27 */ 38 */
28 bool every(bool f(E element)); 39 bool every(bool f(E element));
29 40
30 /** 41 /**
31 * Returns true if one element of this collection satisfies the 42 * Returns true if one element of this collection satisfies the
32 * predicate [f]. Returns false otherwise. 43 * predicate [f]. Returns false otherwise.
33 */ 44 */
34 bool some(bool f(E element)); 45 bool some(bool f(E element));
35 46
36 /** 47 /**
37 * Returns true if there is no element in this collection. 48 * Returns true if there is no element in this collection.
38 */ 49 */
39 bool isEmpty(); 50 bool isEmpty();
40 51
41 /** 52 /**
42 * Returns the number of elements in this collection. 53 * Returns the number of elements in this collection.
43 */ 54 */
44 int get length(); 55 int get length();
45 } 56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698