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

Side by Side Diff: sdk/lib/core/iterable.dart

Issue 12087103: Revert "Rename mappedBy to map." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
« no previous file with comments | « sdk/lib/collection_dev/list.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * The [Iterable] interface allows to get an [Iterator] out of an 8 * The [Iterable] interface allows to get an [Iterator] out of an
9 * [Iterable] object. 9 * [Iterable] object.
10 * 10 *
11 * This interface is used by the for-in construct to iterate over an 11 * This interface is used by the for-in construct to iterate over an
12 * [Iterable] object. 12 * [Iterable] object.
13 * The for-in construct takes an [Iterable] object at the right-hand 13 * The for-in construct takes an [Iterable] object at the right-hand
14 * side, and calls its [iterator] method to get an [Iterator] on it. 14 * side, and calls its [iterator] method to get an [Iterator] on it.
15 * 15 *
16 * A user-defined class that implements the [Iterable] interface can 16 * A user-defined class that implements the [Iterable] interface can
17 * be used as the right-hand side of a for-in construct. 17 * be used as the right-hand side of a for-in construct.
18 */ 18 */
19 abstract class Iterable<E> { 19 abstract class Iterable<E> {
20 const Iterable(); 20 const Iterable();
21 21
22 /** 22 /**
23 * Create an [Iterable] that generates its elements dynamically. 23 * Create an [Iterable] that generates its elements dynamically.
24 * 24 *
25 * The [Iterators] created by the [Iterable] will count from 25 * The [Iterators] created by the [Iterable] will count from
26 * zero to [:count - 1:] while iterating, and call [generator] 26 * zero to [:count - 1:] while iterating, and call [generator]
27 * with that index to create the next value. 27 * with that index to create the next value.
28 * 28 *
29 * As an [Iterable], [:new Iterable.generate(n, generator)):] is equivalent to 29 * As an [Iterable], [:new Iterable.generate(n, generator)):] is equivalent to
30 * [:const [0, ..., n - 1].map(generator):] 30 * [:const [0, ..., n - 1].mappedBy(generator):]
31 */ 31 */
32 factory Iterable.generate(int count, E generator(int index)) { 32 factory Iterable.generate(int count, E generator(int index)) {
33 return new _GeneratorIterable<E>(count, generator); 33 return new _GeneratorIterable<E>(count, generator);
34 } 34 }
35 35
36 /** 36 /**
37 * Returns an [Iterator] that iterates over this [Iterable] object. 37 * Returns an [Iterator] that iterates over this [Iterable] object.
38 */ 38 */
39 Iterator<E> get iterator; 39 Iterator<E> get iterator;
40 40
41 /** 41 /**
42 * Returns a lazy [Iterable] where each element [:e:] of [this] is replaced 42 * Returns a lazy [Iterable] where each element [:e:] of [this] is replaced
43 * by the result of [:f(e):]. 43 * by the result of [:f(e):].
44 * 44 *
45 * This method returns a view of the mapped elements. As long as the 45 * This method returns a view of the mapped elements. As long as the
46 * returned [Iterable] is not iterated over, the supplied function [f] will 46 * returned [Iterable] is not iterated over, the supplied function [f] will
47 * not be invoked. The transformed elements will not be cached. Iterating 47 * not be invoked. The transformed elements will not be cached. Iterating
48 * multiple times over the the returned [Iterable] will invoke the supplied 48 * multiple times over the the returned [Iterable] will invoke the supplied
49 * function [f] multiple times on the same element. 49 * function [f] multiple times on the same element.
50 */ 50 */
51 Iterable map(f(E element)) => new MappedIterable<E, dynamic>(this, f); 51 Iterable mappedBy(f(E element)) => new MappedIterable<E, dynamic>(this, f);
52
53 /**
54 * Deprecated alias for [map].
55 *
56 * @deprecated
57 */
58 Iterable mappedBy(f(E element)) => map(f);
59 52
60 /** 53 /**
61 * Returns a lazy [Iterable] with all elements that satisfy the 54 * Returns a lazy [Iterable] with all elements that satisfy the
62 * predicate [f]. 55 * predicate [f].
63 * 56 *
64 * This method returns a view of the mapped elements. As long as the 57 * This method returns a view of the mapped elements. As long as the
65 * returned [Iterable] is not iterated over, the supplied function [f] will 58 * returned [Iterable] is not iterated over, the supplied function [f] will
66 * not be invoked. Iterating will not cache results, and thus iterating 59 * not be invoked. Iterating will not cache results, and thus iterating
67 * multiple times over the the returned [Iterable] will invoke the supplied 60 * multiple times over the the returned [Iterable] will invoke the supplied
68 * function [f] multiple times on the same element. 61 * function [f] multiple times on the same element.
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 _index++; 406 _index++;
414 return true; 407 return true;
415 } else { 408 } else {
416 _current = null; 409 _current = null;
417 return false; 410 return false;
418 } 411 }
419 } 412 }
420 413
421 E get current => _current; 414 E get current => _current;
422 } 415 }
OLDNEW
« no previous file with comments | « sdk/lib/collection_dev/list.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698