| 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 html; | 5 part of html; |
| 6 | 6 |
| 7 // Iterator for arrays with fixed size. | 7 // Iterator for arrays with fixed size. |
| 8 class FixedSizeListIterator<T> implements Iterator<T> { | 8 class FixedSizeListIterator<T> implements Iterator<T> { |
| 9 final List<T> _array; | 9 final List<T> _array; |
| 10 final int _length; // Cache array length for faster access. | 10 final int _length; // Cache array length for faster access. |
| 11 int _position; | 11 int _position; |
| 12 T _current; | 12 T _current; |
| 13 | 13 |
| 14 FixedSizeListIterator(List<T> array) | 14 FixedSizeListIterator(List<T> array) |
| 15 : _array = array, | 15 : _array = array, |
| 16 _position = -1, | 16 _position = -1, |
| 17 _length = array.length; | 17 _length = array.length; |
| 18 | 18 |
| 19 bool moveNext() { | 19 bool moveNext() { |
| 20 int nextPosition = _position + 1; | 20 int nextPosition = _position + 1; |
| 21 if (nextPosition < _length) { | 21 if (nextPosition < _length) { |
| 22 _current = _array[nextPosition]; | 22 _current = _array[nextPosition]; |
| 23 _position = nextPosition; | 23 _position = nextPosition; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 48 _position = nextPosition; | 48 _position = nextPosition; |
| 49 return true; | 49 return true; |
| 50 } | 50 } |
| 51 _current = null; | 51 _current = null; |
| 52 _position = _array.length; | 52 _position = _array.length; |
| 53 return false; | 53 return false; |
| 54 } | 54 } |
| 55 | 55 |
| 56 T get current => _current; | 56 T get current => _current; |
| 57 } | 57 } |
| OLD | NEW |