| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 if (length > 0) return this[length - 1]; | 154 if (length > 0) return this[length - 1]; |
| 155 throw new StateError("No elements"); | 155 throw new StateError("No elements"); |
| 156 } | 156 } |
| 157 | 157 |
| 158 T get single { | 158 T get single { |
| 159 if (length == 1) return this[0]; | 159 if (length == 1) return this[0]; |
| 160 if (length == 0) throw new StateError("No elements"); | 160 if (length == 0) throw new StateError("No elements"); |
| 161 throw new StateError("More than one element"); | 161 throw new StateError("More than one element"); |
| 162 } | 162 } |
| 163 | 163 |
| 164 int min([int compare(int a, int b)]) => Collections.min(this, compare); |
| 165 |
| 166 int max([int compare(int a, int b)]) => Collections.max(this, compare); |
| 167 |
| 164 int indexOf(T element, [int start = 0]) { | 168 int indexOf(T element, [int start = 0]) { |
| 165 return Arrays.indexOf(this, element, start, length); | 169 return Arrays.indexOf(this, element, start, length); |
| 166 } | 170 } |
| 167 | 171 |
| 168 int lastIndexOf(T element, [int start = null]) { | 172 int lastIndexOf(T element, [int start = null]) { |
| 169 if (start == null) start = length - 1; | 173 if (start == null) start = length - 1; |
| 170 return Arrays.lastIndexOf(this, element, start); | 174 return Arrays.lastIndexOf(this, element, start); |
| 171 } | 175 } |
| 172 | 176 |
| 173 void _grow(int new_length) { | 177 void _grow(int new_length) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 288 } |
| 285 | 289 |
| 286 List<T> toList() { | 290 List<T> toList() { |
| 287 return new List<T>.from(this); | 291 return new List<T>.from(this); |
| 288 } | 292 } |
| 289 | 293 |
| 290 Set<T> toSet() { | 294 Set<T> toSet() { |
| 291 return new Set<T>.from(this); | 295 return new Set<T>.from(this); |
| 292 } | 296 } |
| 293 } | 297 } |
| OLD | NEW |