| 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 |
| 11 E operator [](int index) native "ObjectArray_getIndexed"; | 11 E operator [](int index) native "ObjectArray_getIndexed"; |
| 12 | 12 |
| 13 void operator []=(int index, E value) native "ObjectArray_setIndexed"; | 13 void operator []=(int index, E value) native "ObjectArray_setIndexed"; |
| 14 | 14 |
| 15 String toString() { | 15 String toString() { |
| 16 return Collections.collectionToString(this); | 16 return Collections.collectionToString(this); |
| 17 } | 17 } |
| 18 | 18 |
| 19 int get length() native "ObjectArray_getLength"; | 19 int get length native "ObjectArray_getLength"; |
| 20 | 20 |
| 21 void _copyFromObjectArray(ObjectArray src, | 21 void _copyFromObjectArray(ObjectArray src, |
| 22 int srcStart, | 22 int srcStart, |
| 23 int dstStart, | 23 int dstStart, |
| 24 int count) | 24 int count) |
| 25 native "ObjectArray_copyFromObjectArray"; | 25 native "ObjectArray_copyFromObjectArray"; |
| 26 | 26 |
| 27 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { | 27 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { |
| 28 if (length < 0) { | 28 if (length < 0) { |
| 29 throw new IllegalArgumentException("negative length $length"); | 29 throw new IllegalArgumentException("negative length $length"); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 "ImmutableArray can only be allocated by the VM"); | 152 "ImmutableArray can only be allocated by the VM"); |
| 153 } | 153 } |
| 154 | 154 |
| 155 E operator [](int index) native "ObjectArray_getIndexed"; | 155 E operator [](int index) native "ObjectArray_getIndexed"; |
| 156 | 156 |
| 157 void operator []=(int index, E value) { | 157 void operator []=(int index, E value) { |
| 158 throw const UnsupportedOperationException( | 158 throw const UnsupportedOperationException( |
| 159 "Cannot modify an immutable array"); | 159 "Cannot modify an immutable array"); |
| 160 } | 160 } |
| 161 | 161 |
| 162 int get length() native "ObjectArray_getLength"; | 162 int get length native "ObjectArray_getLength"; |
| 163 | 163 |
| 164 void copyFrom(List src, int srcStart, int dstStart, int count) { | 164 void copyFrom(List src, int srcStart, int dstStart, int count) { |
| 165 throw const UnsupportedOperationException( | 165 throw const UnsupportedOperationException( |
| 166 "Cannot modify an immutable array"); | 166 "Cannot modify an immutable array"); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { | 169 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { |
| 170 throw const UnsupportedOperationException( | 170 throw const UnsupportedOperationException( |
| 171 "Cannot modify an immutable array"); | 171 "Cannot modify an immutable array"); |
| 172 } | 172 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 if (!hasNext()) { | 294 if (!hasNext()) { |
| 295 throw const NoMoreElementsException(); | 295 throw const NoMoreElementsException(); |
| 296 } | 296 } |
| 297 return _array[_pos++]; | 297 return _array[_pos++]; |
| 298 } | 298 } |
| 299 | 299 |
| 300 final List<E> _array; | 300 final List<E> _array; |
| 301 final int _length; // Cache array length for faster access. | 301 final int _length; // Cache array length for faster access. |
| 302 int _pos; | 302 int _pos; |
| 303 } | 303 } |
| OLD | NEW |