| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 ObjectArray<T> backingArray; | 6 ObjectArray<T> backingArray; |
| 7 | 7 |
| 8 factory GrowableObjectArray<T>._uninstantiable() { | 8 factory GrowableObjectArray._uninstantiable() { |
| 9 throw const UnsupportedOperationException( | 9 throw const UnsupportedOperationException( |
| 10 "GrowableObjectArray can only be allocated by the VM"); | 10 "GrowableObjectArray can only be allocated by the VM"); |
| 11 } | 11 } |
| 12 | 12 |
| 13 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 13 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
| 14 Arrays.copy(src, srcStart, this, dstStart, count); | 14 Arrays.copy(src, srcStart, this, dstStart, count); |
| 15 } | 15 } |
| 16 | 16 |
| 17 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { | 17 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { |
| 18 if (length < 0) { | 18 if (length < 0) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 : _length = 0, backingArray = new ObjectArray<T>(4) {} | 87 : _length = 0, backingArray = new ObjectArray<T>(4) {} |
| 88 | 88 |
| 89 GrowableObjectArray.withCapacity(int capacity) { | 89 GrowableObjectArray.withCapacity(int capacity) { |
| 90 _length = 0; | 90 _length = 0; |
| 91 if (capacity <= 0) { | 91 if (capacity <= 0) { |
| 92 capacity = 4; | 92 capacity = 4; |
| 93 } | 93 } |
| 94 backingArray = new ObjectArray<T>(capacity); | 94 backingArray = new ObjectArray<T>(capacity); |
| 95 } | 95 } |
| 96 | 96 |
| 97 factory GrowableObjectArray<T>.from(Collection<T> other) { | 97 factory GrowableObjectArray.from(Collection<T> other) { |
| 98 List<T> result = new GrowableObjectArray<T>(); | 98 List<T> result = new GrowableObjectArray<T>(); |
| 99 result.addAll(other); | 99 result.addAll(other); |
| 100 return result; | 100 return result; |
| 101 } | 101 } |
| 102 | 102 |
| 103 int get length() { | 103 int get length() { |
| 104 return _length; | 104 return _length; |
| 105 } | 105 } |
| 106 | 106 |
| 107 void set length(int new_length) { | 107 void set length(int new_length) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 if (!hasNext()) { | 239 if (!hasNext()) { |
| 240 throw const NoMoreElementsException(); | 240 throw const NoMoreElementsException(); |
| 241 } | 241 } |
| 242 return _array[_pos++]; | 242 return _array[_pos++]; |
| 243 } | 243 } |
| 244 | 244 |
| 245 final GrowableObjectArray<T> _array; | 245 final GrowableObjectArray<T> _array; |
| 246 int _pos; | 246 int _pos; |
| 247 } | 247 } |
| 248 | 248 |
| OLD | NEW |