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

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

Issue 14468004: Fix missing concurrency check in [].forEach. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added comment about iteration order of lists. Created 7 years, 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 * A [List] is an indexable collection with a length. 8 * A [List] is an indexable collection with a length.
9 * 9 *
10 * A `List` implementation can choose not to support all methods 10 * A `List` implementation can choose not to support all methods
(...skipping 15 matching lines...) Expand all
26 * fixedLengthList.add(499); // throws 26 * fixedLengthList.add(499); // throws
27 * fixedLengthList[0] = 87; 27 * fixedLengthList[0] = 87;
28 * var growableList = [1, 2]; 28 * var growableList = [1, 2];
29 * growableList.length = 0; 29 * growableList.length = 0;
30 * growableList.add(499); 30 * growableList.add(499);
31 * growableList[0] = 87; 31 * growableList[0] = 87;
32 * var unmodifiableList = const [1, 2]; 32 * var unmodifiableList = const [1, 2];
33 * unmodifiableList.length = 0; // throws. 33 * unmodifiableList.length = 0; // throws.
34 * unmodifiableList.add(499); // throws 34 * unmodifiableList.add(499); // throws
35 * unmodifiableList[0] = 87; // throws. 35 * unmodifiableList[0] = 87; // throws.
36 *
37 * Lists are [Iterable].
38 * List iteration iterates over values in index order.
39 * Changing the values will not affect iteration,
40 * but changing the valid indices -
41 * that is, changing the list's length -
42 * between iteration steps
43 * will cause a [ConcurrentModificationError].
44 * This means that only growable lists can throw [ConcurrentModificationError].
45 * If the length changes temporarily
46 * and is restored before continuing the iteration,
47 * the iterator will not detect it.
hausner 2013/04/25 23:07:17 Right. So why add the check?
36 */ 48 */
37 abstract class List<E> implements Iterable<E> { 49 abstract class List<E> implements Iterable<E> {
38 /** 50 /**
39 * Creates a list of the given [length]. 51 * Creates a list of the given [length].
40 * 52 *
41 * The list is a fixed-length list if [length] is provided, and an empty 53 * The list is a fixed-length list if [length] is provided, and an empty
42 * growable list if [length] is omitted. 54 * growable list if [length] is omitted.
43 */ 55 */
44 external factory List([int length]); 56 external factory List([int length]);
45 57
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 void replaceRange(int start, int end, Iterable<E> iterable); 346 void replaceRange(int start, int end, Iterable<E> iterable);
335 347
336 /** 348 /**
337 * Returns an unmodifiable [Map] view of `this`. 349 * Returns an unmodifiable [Map] view of `this`.
338 * 350 *
339 * It has the indices of this list as keys, and the corresponding elements 351 * It has the indices of this list as keys, and the corresponding elements
340 * as values. 352 * as values.
341 */ 353 */
342 Map<int, E> asMap(); 354 Map<int, E> asMap();
343 } 355 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698