| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.collection.dev; | 5 part of dart.collection.dev; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Class implementing the read-operations on [List]. | 8 * Class implementing the read-operations on [List]. |
| 9 * | 9 * |
| 10 * Implements all read-only operations, except [:operator[]:] and [:length:], | 10 * Implements all read-only operations, except [:operator[]:] and [:length:], |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 throw new UnsupportedError( | 266 throw new UnsupportedError( |
| 267 "Cannot insert range in an unmodifiable list"); | 267 "Cannot insert range in an unmodifiable list"); |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 /** | 271 /** |
| 272 * Iterates over a [List] in growing index order. | 272 * Iterates over a [List] in growing index order. |
| 273 */ | 273 */ |
| 274 class ListIterator<E> implements Iterator<E> { | 274 class ListIterator<E> implements Iterator<E> { |
| 275 final List<E> _list; | 275 final List<E> _list; |
| 276 final int _initialLength; |
| 276 int _position; | 277 int _position; |
| 277 E _current; | 278 E _current; |
| 278 | 279 |
| 279 ListIterator(List<E> list) : _list = list, _position = -1; | 280 ListIterator(List<E> list) |
| 281 : _list = list, _position = -1, _initialLength = list.length; |
| 280 | 282 |
| 281 bool moveNext() { | 283 bool moveNext() { |
| 284 if (_list.length != _initialLength) { |
| 285 throw new ConcurrentModificationError(_list); |
| 286 } |
| 282 int nextPosition = _position + 1; | 287 int nextPosition = _position + 1; |
| 283 if (nextPosition < _list.length) { | 288 if (nextPosition < _list.length) { |
| 284 _current = _list[nextPosition]; | 289 _current = _list[nextPosition]; |
| 285 _position = nextPosition; | 290 _position = nextPosition; |
| 286 return true; | 291 return true; |
| 287 } | 292 } |
| 288 _position = _list.length; | 293 _position = _list.length; |
| 289 _current = null; | 294 _current = null; |
| 290 return false; | 295 return false; |
| 291 } | 296 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 throw new ConcurrentModificationError(list); | 523 throw new ConcurrentModificationError(list); |
| 519 } | 524 } |
| 520 if (_index <= _start) return false; | 525 if (_index <= _start) return false; |
| 521 _index -= 1; | 526 _index -= 1; |
| 522 _current = _list[_index]; | 527 _current = _list[_index]; |
| 523 return true; | 528 return true; |
| 524 } | 529 } |
| 525 | 530 |
| 526 E get current => _current; | 531 E get current => _current; |
| 527 } | 532 } |
| OLD | NEW |