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; |
| 6 |
5 // Iterator for arrays with fixed size. | 7 // Iterator for arrays with fixed size. |
6 class _FixedSizeListIterator<T> extends _VariableSizeListIterator<T> { | 8 class _FixedSizeListIterator<T> extends _VariableSizeListIterator<T> { |
7 _FixedSizeListIterator(List<T> array) | 9 _FixedSizeListIterator(List<T> array) |
8 : super(array), | 10 : super(array), |
9 _length = array.length; | 11 _length = array.length; |
10 | 12 |
11 bool get hasNext => _length > _pos; | 13 bool get hasNext => _length > _pos; |
12 | 14 |
13 final int _length; // Cache array length for faster access. | 15 final int _length; // Cache array length for faster access. |
14 } | 16 } |
15 | 17 |
16 // Iterator for arrays with variable size. | 18 // Iterator for arrays with variable size. |
17 class _VariableSizeListIterator<T> implements Iterator<T> { | 19 class _VariableSizeListIterator<T> implements Iterator<T> { |
18 _VariableSizeListIterator(List<T> array) | 20 _VariableSizeListIterator(List<T> array) |
19 : _array = array, | 21 : _array = array, |
20 _pos = 0; | 22 _pos = 0; |
21 | 23 |
22 bool get hasNext => _array.length > _pos; | 24 bool get hasNext => _array.length > _pos; |
23 | 25 |
24 T next() { | 26 T next() { |
25 if (!hasNext) { | 27 if (!hasNext) { |
26 throw new StateError("No more elements"); | 28 throw new StateError("No more elements"); |
27 } | 29 } |
28 return _array[_pos++]; | 30 return _array[_pos++]; |
29 } | 31 } |
30 | 32 |
31 final List<T> _array; | 33 final List<T> _array; |
32 int _pos; | 34 int _pos; |
33 } | 35 } |
OLD | NEW |