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

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

Issue 27308003: Document that concurrent modification is bad, m'kay. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cannot be misread as iterating changing the length. Created 7 years, 2 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/queue.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 * 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 *
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
31 * the iteration, which is typically signalled by throwing a
32 * [ConcurrentModificationError] when it is detected.
28 */ 33 */
29 abstract class Iterable<E> { 34 abstract class Iterable<E> {
30 const Iterable(); 35 const Iterable();
31 36
32 /** 37 /**
33 * Creates an Iterable that generates its elements dynamically. 38 * Creates an Iterable that generates its elements dynamically.
34 * 39 *
35 * The Iterators created by the Iterable count from 40 * The Iterators created by the Iterable count from
36 * zero to [:count - 1:] while iterating, and call [generator] 41 * zero to [:count - 1:] while iterating, and call [generator]
37 * with that index to create the next value. 42 * with that index to create the next value.
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 */ 323 */
319 abstract class BidirectionalIterator<E> implements Iterator<E> { 324 abstract class BidirectionalIterator<E> implements Iterator<E> {
320 /** 325 /**
321 * Move back to the previous element. 326 * Move back to the previous element.
322 * 327 *
323 * Returns true and updates [current] if successful. Returns false 328 * Returns true and updates [current] if successful. Returns false
324 * and sets [current] to null if there is no previous element. 329 * and sets [current] to null if there is no previous element.
325 */ 330 */
326 bool movePrevious(); 331 bool movePrevious();
327 } 332 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/queue.dart ('k') | sdk/lib/core/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698