Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * | |
| 19 * Iterating over an iterable should not have side effects. | |
| 20 * If someone receives an iterable, they should be free to iterate it more | |
| 21 * than once (for example once to get the length, and then once to do something | |
|
floitsch
2013/03/12 16:25:00
Doesn't fit this CL.
Also I don't necessarily agre
Lasse Reichstein Nielsen
2013/03/13 13:01:42
Removed for now.
| |
| 22 * for each element). | |
| 18 */ | 23 */ |
| 19 abstract class Iterable<E> { | 24 abstract class Iterable<E> { |
| 20 const Iterable(); | 25 const Iterable(); |
| 21 | 26 |
| 22 /** | 27 /** |
| 23 * Create an [Iterable] that generates its elements dynamically. | 28 * Create an [Iterable] that generates its elements dynamically. |
| 24 * | 29 * |
| 25 * The [Iterators] created by the [Iterable] will count from | 30 * The [Iterators] created by the [Iterable] will count from |
| 26 * zero to [:count - 1:] while iterating, and call [generator] | 31 * zero to [:count - 1:] while iterating, and call [generator] |
| 27 * with that index to create the next value. | 32 * with that index to create the next value. |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 */ | 438 */ |
| 434 abstract class BidirectionalIterator<T> extends Iterator<T> { | 439 abstract class BidirectionalIterator<T> extends Iterator<T> { |
| 435 /** | 440 /** |
| 436 * Move back to the previous element. | 441 * Move back to the previous element. |
| 437 * | 442 * |
| 438 * Returns true and updates [current] if successful. Returns false | 443 * Returns true and updates [current] if successful. Returns false |
| 439 * and sets [current] to null if there is no previous element. | 444 * and sets [current] to null if there is no previous element. |
| 440 */ | 445 */ |
| 441 bool movePrevious(); | 446 bool movePrevious(); |
| 442 } | 447 } |
| OLD | NEW |