| OLD | NEW |
| 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 class ListFactory<E> { | 5 class ListFactory<E> { |
| 6 | 6 |
| 7 factory List.from(Iterable<E> other) { | 7 factory List.from(Iterable<E> other) { |
| 8 GrowableObjectArray<E> list = new GrowableObjectArray<E>(); | 8 GrowableObjectArray<E> list = new GrowableObjectArray<E>(); |
| 9 for (final e in other) { | 9 for (final e in other) { |
| 10 list.add(e); | 10 list.add(e); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 | 295 |
| 296 // Iterator for arrays with fixed size. | 296 // Iterator for arrays with fixed size. |
| 297 class FixedSizeArrayIterator<E> implements Iterator<E> { | 297 class FixedSizeArrayIterator<E> implements Iterator<E> { |
| 298 FixedSizeArrayIterator(List array) | 298 FixedSizeArrayIterator(List array) |
| 299 : _array = array, _length = array.length, _pos = 0 { | 299 : _array = array, _length = array.length, _pos = 0 { |
| 300 assert(array is ObjectArray || array is ImmutableArray); | 300 assert(array is ObjectArray || array is ImmutableArray); |
| 301 } | 301 } |
| 302 | 302 |
| 303 bool hasNext() { | 303 bool hasNext() { |
| 304 return _length > _pos; | 304 return _length > _pos; |
| 305 } | 305 } |
| 306 | 306 |
| 307 E next() { | 307 E next() { |
| 308 if (!hasNext()) { | 308 if (!hasNext()) { |
| 309 throw const NoMoreElementsException(); | 309 throw const NoMoreElementsException(); |
| 310 } | 310 } |
| 311 return _array[_pos++]; | 311 return _array[_pos++]; |
| 312 } | 312 } |
| 313 | 313 |
| 314 final List<E> _array; | 314 final List<E> _array; |
| 315 final int _length; // Cache array length for faster access. | 315 final int _length; // Cache array length for faster access. |
| 316 int _pos; | 316 int _pos; |
| 317 } | 317 } |
| OLD | NEW |