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

Unified Diff: sdk/lib/collection_dev/list.dart

Issue 12040018: Make ListIterator throw if the underlying list's length changes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/corelib/list_iterators_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection_dev/list.dart
diff --git a/sdk/lib/collection_dev/list.dart b/sdk/lib/collection_dev/list.dart
index cddc75a762baf32e1a11c10c169e6481cf8cb964..34614f691c5f36e64a6085149b6529a581d79dd9 100644
--- a/sdk/lib/collection_dev/list.dart
+++ b/sdk/lib/collection_dev/list.dart
@@ -273,12 +273,17 @@ abstract class UnmodifiableListBase<E> extends ListBase<E> {
*/
class ListIterator<E> implements Iterator<E> {
final List<E> _list;
+ final int _initialLength;
int _position;
E _current;
- ListIterator(List<E> list) : _list = list, _position = -1;
+ ListIterator(List<E> list)
+ : _list = list, _position = -1, _initialLength = list.length;
bool moveNext() {
+ if (_list.length != _initialLength) {
+ throw new ConcurrentModificationError(_list);
+ }
int nextPosition = _position + 1;
if (nextPosition < _list.length) {
_current = _list[nextPosition];
« no previous file with comments | « no previous file | tests/corelib/list_iterators_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698