| 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 | 5 |
| 6 // TODO(srdjan): Use shared array implementation. | 6 // TODO(srdjan): Use shared array implementation. |
| 7 class _ObjectArray<E> implements List<E> { | 7 class _ObjectArray<E> implements List<E> { |
| 8 | 8 |
| 9 factory _ObjectArray(int length) native "ObjectArray_allocate"; | 9 factory _ObjectArray(int length) native "ObjectArray_allocate"; |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 E removeAt(int index) { | 27 E removeAt(int index) { |
| 28 throw new UnsupportedError( | 28 throw new UnsupportedError( |
| 29 "Cannot remove element of a non-extendable array"); | 29 "Cannot remove element of a non-extendable array"); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { | 32 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { |
| 33 if (length < 0) { | 33 if (length < 0) { |
| 34 throw new ArgumentError("negative length $length"); | 34 throw new ArgumentError("negative length $length"); |
| 35 } | 35 } |
| 36 if (from is _ObjectArray) { | 36 if (from is _ObjectArray) { |
| 37 _copyFromObjectArray(from, startFrom, start, length); | 37 _copyFromObjectArray(from, startFrom, start, length); |
| 38 } else { | 38 } else { |
| 39 Arrays.copy(from, startFrom, this, start, length); | 39 Arrays.copy(from, startFrom, this, start, length); |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 void removeRange(int start, int length) { | 43 void removeRange(int start, int length) { |
| 44 throw new UnsupportedError( | 44 throw new UnsupportedError( |
| 45 "Cannot remove range of a non-extendable array"); | 45 "Cannot remove range of a non-extendable array"); |
| 46 } | 46 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 if (!hasNext) { | 315 if (!hasNext) { |
| 316 throw new StateError("No more elements"); | 316 throw new StateError("No more elements"); |
| 317 } | 317 } |
| 318 return _array[_pos++]; | 318 return _array[_pos++]; |
| 319 } | 319 } |
| 320 | 320 |
| 321 final List<E> _array; | 321 final List<E> _array; |
| 322 final int _length; // Cache array length for faster access. | 322 final int _length; // Cache array length for faster access. |
| 323 int _pos; | 323 int _pos; |
| 324 } | 324 } |
| OLD | NEW |