| 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 30 matching lines...) Expand all Loading... |
| 41 void removeMatching(bool test(T element)) { | 41 void removeMatching(bool test(T element)) { |
| 42 IterableMixinWorkaround.removeMatchingList(this, test); | 42 IterableMixinWorkaround.removeMatchingList(this, test); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void retainMatching(bool test(T element)) { | 45 void retainMatching(bool test(T element)) { |
| 46 IterableMixinWorkaround.removeMatchingList(this, | 46 IterableMixinWorkaround.removeMatchingList(this, |
| 47 (T element) => !test(element)); | 47 (T element) => !test(element)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { | 50 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { |
| 51 if (length < 0) { | 51 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); |
| 52 throw new ArgumentError("negative length $length"); | |
| 53 } | |
| 54 Arrays.copy(from, startFrom, this, start, length); | |
| 55 } | 52 } |
| 56 | 53 |
| 57 void removeRange(int start, int length) { | 54 void removeRange(int start, int length) { |
| 58 if (length == 0) { | 55 if (length == 0) { |
| 59 return; | 56 return; |
| 60 } | 57 } |
| 61 Arrays.rangeCheck(this, start, length); | 58 Arrays.rangeCheck(this, start, length); |
| 62 Arrays.copy(this, | 59 Arrays.copy(this, |
| 63 start + length, | 60 start + length, |
| 64 this, | 61 this, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 if (length == 1) return this[0]; | 184 if (length == 1) return this[0]; |
| 188 if (length == 0) throw new StateError("No elements"); | 185 if (length == 0) throw new StateError("No elements"); |
| 189 throw new StateError("More than one element"); | 186 throw new StateError("More than one element"); |
| 190 } | 187 } |
| 191 | 188 |
| 192 T min([int compare(T a, T b)]) => IterableMixinWorkaround.min(this, compare); | 189 T min([int compare(T a, T b)]) => IterableMixinWorkaround.min(this, compare); |
| 193 | 190 |
| 194 T max([int compare(T a, T b)]) => IterableMixinWorkaround.max(this, compare); | 191 T max([int compare(T a, T b)]) => IterableMixinWorkaround.max(this, compare); |
| 195 | 192 |
| 196 int indexOf(T element, [int start = 0]) { | 193 int indexOf(T element, [int start = 0]) { |
| 197 return Arrays.indexOf(this, element, start, length); | 194 return IterableMixinWorkaround.indexOfList(this, element, start); |
| 198 } | 195 } |
| 199 | 196 |
| 200 int lastIndexOf(T element, [int start = null]) { | 197 int lastIndexOf(T element, [int start = null]) { |
| 201 if (start == null) start = length - 1; | 198 return IterableMixinWorkaround.lastIndexOfList(this, element, start); |
| 202 return Arrays.lastIndexOf(this, element, start); | |
| 203 } | 199 } |
| 204 | 200 |
| 205 void _grow(int new_length) { | 201 void _grow(int new_length) { |
| 206 var new_data = new _ObjectArray(new_length); | 202 var new_data = new _ObjectArray(new_length); |
| 207 for (int i = 0; i < length; i++) { | 203 for (int i = 0; i < length; i++) { |
| 208 new_data[i] = this[i]; | 204 new_data[i] = this[i]; |
| 209 } | 205 } |
| 210 _setData(new_data); | 206 _setData(new_data); |
| 211 } | 207 } |
| 212 | 208 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 321 } |
| 326 | 322 |
| 327 Set<T> toSet() { | 323 Set<T> toSet() { |
| 328 return new Set<T>.from(this); | 324 return new Set<T>.from(this); |
| 329 } | 325 } |
| 330 | 326 |
| 331 Map<int, T> asMap() { | 327 Map<int, T> asMap() { |
| 332 return IterableMixinWorkaround.asMapList(this); | 328 return IterableMixinWorkaround.asMapList(this); |
| 333 } | 329 } |
| 334 } | 330 } |
| OLD | NEW |