| 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 new UnsupportedError( | 7 throw new UnsupportedError( |
| 8 "GrowableObjectArray can only be allocated by the VM"); | 8 "GrowableObjectArray can only be allocated by the VM"); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 if (start == end) return <T>[]; | 121 if (start == end) return <T>[]; |
| 122 List list = new _GrowableObjectArray<T>.withCapacity(length); | 122 List list = new _GrowableObjectArray<T>.withCapacity(length); |
| 123 list.length = length; | 123 list.length = length; |
| 124 Arrays.copy(this, start, list, 0, length); | 124 Arrays.copy(this, start, list, 0, length); |
| 125 return list; | 125 return list; |
| 126 } | 126 } |
| 127 | 127 |
| 128 factory _GrowableObjectArray(int length) { | 128 factory _GrowableObjectArray(int length) { |
| 129 var data = new _ObjectArray((length == 0) ? 4 : length); | 129 var data = new _ObjectArray((length == 0) ? 4 : length); |
| 130 var result = new _GrowableObjectArray<T>.withData(data); | 130 var result = new _GrowableObjectArray<T>.withData(data); |
| 131 result._setLength(length); | 131 if (length > 0) { |
| 132 result._setLength(length); |
| 133 } |
| 132 return result; | 134 return result; |
| 133 } | 135 } |
| 134 | 136 |
| 135 factory _GrowableObjectArray.withCapacity(int capacity) { | 137 factory _GrowableObjectArray.withCapacity(int capacity) { |
| 136 var data = new _ObjectArray((capacity == 0)? 4 : capacity); | 138 var data = new _ObjectArray((capacity == 0)? 4 : capacity); |
| 137 return new _GrowableObjectArray<T>.withData(data); | 139 return new _GrowableObjectArray<T>.withData(data); |
| 138 } | 140 } |
| 139 | 141 |
| 140 factory _GrowableObjectArray.from(Iterable<T> other) { | 142 factory _GrowableObjectArray.from(Iterable<T> other) { |
| 141 List<T> result = new _GrowableObjectArray<T>(); | 143 List<T> result = new _GrowableObjectArray<T>(); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 349 } |
| 348 | 350 |
| 349 Set<T> toSet() { | 351 Set<T> toSet() { |
| 350 return new Set<T>.from(this); | 352 return new Set<T>.from(this); |
| 351 } | 353 } |
| 352 | 354 |
| 353 Map<int, T> asMap() { | 355 Map<int, T> asMap() { |
| 354 return IterableMixinWorkaround.asMapList(this); | 356 return IterableMixinWorkaround.asMapList(this); |
| 355 } | 357 } |
| 356 } | 358 } |
| OLD | NEW |