| 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 * An object that uses an [Iterator] to serve objects one at a time. | 8 * An object that uses an [Iterator] to serve objects one at a time. |
| 9 * | 9 * |
| 10 * You can iterate over all objects served by an Iterable object | 10 * You can iterate over all objects served by an Iterable object |
| 11 * using the for-in loop construct. | 11 * using the for-in loop construct. |
| 12 * For example, you can iterate over all of the keys in a [Map], | 12 * For example, you can iterate over all of the keys in a [Map], |
| 13 * because Map keys are iterable. | 13 * because Map keys are iterable. |
| 14 * | 14 * |
| 15 * Map kidsBooks = {'Matilda': 'Roald Dahl', | 15 * Map kidsBooks = {'Matilda': 'Roald Dahl', |
| 16 * 'Green Eggs and Ham': 'Dr Seuss', | 16 * 'Green Eggs and Ham': 'Dr Seuss', |
| 17 * 'Where the Wild Things Are': 'Maurice Sendak'}; | 17 * 'Where the Wild Things Are': 'Maurice Sendak'}; |
| 18 * for (var book in kidsBooks.keys) { | 18 * for (var book in kidsBooks.keys) { |
| 19 * print('$book was written by ${kidsBooks[book]}'); | 19 * print('$book was written by ${kidsBooks[book]}'); |
| 20 * } | 20 * } |
| 21 * | 21 * |
| 22 * The [List] class and the [Set] class implement this interface, | 22 * The [List] class and the [Set] class implement this interface, |
| 23 * as do classes in the [dart:collection](#dart-collection) library. | 23 * as do classes in the [dart:collection](#dart-collection) library. |
| 24 * | 24 * |
| 25 * You can implement Iterable in your own class. | 25 * You can implement Iterable in your own class. |
| 26 * If you do, then an instance of your Iterable class | 26 * If you do, then an instance of your Iterable class |
| 27 * can be the right-hand side of a for-in construct. | 27 * can be the right-hand side of a for-in construct. |
| 28 * | 28 * |
| 29 * Some subclasss of `Iterable` can be modified. It is generally not allowed | 29 * Some subclasss of [Iterable] can be modified. It is generally not allowed |
| 30 * to modify such collections while they are being iterated. Doing so will break | 30 * to modify such collections while they are being iterated. Doing so will break |
| 31 * the iteration, which is typically signalled by throwing a | 31 * the iteration, which is typically signalled by throwing a |
| 32 * [ConcurrentModificationError] when it is detected. | 32 * [ConcurrentModificationError] when it is detected. |
| 33 */ | 33 */ |
| 34 abstract class Iterable<E> { | 34 abstract class Iterable<E> { |
| 35 const Iterable(); | 35 const Iterable(); |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Creates an Iterable that generates its elements dynamically. | 38 * Creates an Iterable that generates its elements dynamically. |
| 39 * | 39 * |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 */ | 323 */ |
| 324 abstract class BidirectionalIterator<E> implements Iterator<E> { | 324 abstract class BidirectionalIterator<E> implements Iterator<E> { |
| 325 /** | 325 /** |
| 326 * Move back to the previous element. | 326 * Move back to the previous element. |
| 327 * | 327 * |
| 328 * Returns true and updates [current] if successful. Returns false | 328 * Returns true and updates [current] if successful. Returns false |
| 329 * and sets [current] to null if there is no previous element. | 329 * and sets [current] to null if there is no previous element. |
| 330 */ | 330 */ |
| 331 bool movePrevious(); | 331 bool movePrevious(); |
| 332 } | 332 } |
| OLD | NEW |