| 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 GrowableObjectArray<T> implements List<T> { | 5 class GrowableObjectArray<T> implements List<T> { |
| 6 factory GrowableObjectArray._uninstantiable() { | 6 factory GrowableObjectArray._uninstantiable() { |
| 7 throw const UnsupportedOperationException( | 7 throw const UnsupportedOperationException( |
| 8 "GrowableObjectArray can only be allocated by the VM"); | 8 "GrowableObjectArray can only be allocated by the VM"); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 factory GrowableObjectArray.from(Collection<T> other) { | 72 factory GrowableObjectArray.from(Collection<T> other) { |
| 73 List<T> result = new GrowableObjectArray<T>(); | 73 List<T> result = new GrowableObjectArray<T>(); |
| 74 result.addAll(other); | 74 result.addAll(other); |
| 75 return result; | 75 return result; |
| 76 } | 76 } |
| 77 | 77 |
| 78 factory GrowableObjectArray.fromObjectArray(ObjectArray<T> data) | 78 factory GrowableObjectArray.fromObjectArray(ObjectArray<T> data) |
| 79 native "GrowableObjectArray_allocate"; | 79 native "GrowableObjectArray_allocate"; |
| 80 | 80 |
| 81 int get length() native "GrowableObjectArray_getLength"; | 81 int get length native "GrowableObjectArray_getLength"; |
| 82 | 82 |
| 83 int get capacity() native "GrowableObjectArray_getCapacity"; | 83 int get capacity native "GrowableObjectArray_getCapacity"; |
| 84 | 84 |
| 85 void set length(int new_length) { | 85 void set length(int new_length) { |
| 86 if (new_length > capacity) { | 86 if (new_length > capacity) { |
| 87 _grow(new_length); | 87 _grow(new_length); |
| 88 } else { | 88 } else { |
| 89 for (int i = new_length; i < length; i++) { | 89 for (int i = new_length; i < length; i++) { |
| 90 this[i] = null; | 90 this[i] = null; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 _setLength(new_length); | 93 _setLength(new_length); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 T next() { | 227 T next() { |
| 228 if (!hasNext()) { | 228 if (!hasNext()) { |
| 229 throw const NoMoreElementsException(); | 229 throw const NoMoreElementsException(); |
| 230 } | 230 } |
| 231 return _array[_pos++]; | 231 return _array[_pos++]; |
| 232 } | 232 } |
| 233 | 233 |
| 234 final GrowableObjectArray<T> _array; | 234 final GrowableObjectArray<T> _array; |
| 235 int _pos; | 235 int _pos; |
| 236 } | 236 } |
| OLD | NEW |