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 13 matching lines...) Expand all Loading... |
24 int count) | 24 int count) |
25 native "ObjectArray_copyFromObjectArray"; | 25 native "ObjectArray_copyFromObjectArray"; |
26 | 26 |
27 E removeAt(int index) { | 27 E removeAt(int index) { |
28 throw const UnsupportedOperationException( | 28 throw const UnsupportedOperationException( |
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 IllegalArgumentException("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 const UnsupportedOperationException( | 44 throw const UnsupportedOperationException( |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 if (!hasNext()) { | 304 if (!hasNext()) { |
305 throw const NoMoreElementsException(); | 305 throw const NoMoreElementsException(); |
306 } | 306 } |
307 return _array[_pos++]; | 307 return _array[_pos++]; |
308 } | 308 } |
309 | 309 |
310 final List<E> _array; | 310 final List<E> _array; |
311 final int _length; // Cache array length for faster access. | 311 final int _length; // Cache array length for faster access. |
312 int _pos; | 312 int _pos; |
313 } | 313 } |
OLD | NEW |