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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 if (length > 0) return this[length - 1]; | 201 if (length > 0) return this[length - 1]; |
202 throw new StateError("No elements"); | 202 throw new StateError("No elements"); |
203 } | 203 } |
204 | 204 |
205 T get single { | 205 T get single { |
206 if (length == 1) return this[0]; | 206 if (length == 1) return this[0]; |
207 if (length == 0) throw new StateError("No elements"); | 207 if (length == 0) throw new StateError("No elements"); |
208 throw new StateError("More than one element"); | 208 throw new StateError("More than one element"); |
209 } | 209 } |
210 | 210 |
211 T min([int compare(T a, T b)]) => IterableMixinWorkaround.min(this, compare); | |
212 | |
213 T max([int compare(T a, T b)]) => IterableMixinWorkaround.max(this, compare); | |
214 | |
215 int indexOf(T element, [int start = 0]) { | 211 int indexOf(T element, [int start = 0]) { |
216 return IterableMixinWorkaround.indexOfList(this, element, start); | 212 return IterableMixinWorkaround.indexOfList(this, element, start); |
217 } | 213 } |
218 | 214 |
219 int lastIndexOf(T element, [int start = null]) { | 215 int lastIndexOf(T element, [int start = null]) { |
220 return IterableMixinWorkaround.lastIndexOfList(this, element, start); | 216 return IterableMixinWorkaround.lastIndexOfList(this, element, start); |
221 } | 217 } |
222 | 218 |
223 void _grow(int new_length) { | 219 void _grow(int new_length) { |
224 var new_data = new _ObjectArray(new_length); | 220 var new_data = new _ObjectArray(new_length); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 buffer.write("${this[i]}"); | 253 buffer.write("${this[i]}"); |
258 } | 254 } |
259 } | 255 } |
260 return buffer.toString(); | 256 return buffer.toString(); |
261 } | 257 } |
262 | 258 |
263 Iterable map(f(T element)) { | 259 Iterable map(f(T element)) { |
264 return IterableMixinWorkaround.mapList(this, f); | 260 return IterableMixinWorkaround.mapList(this, f); |
265 } | 261 } |
266 | 262 |
267 reduce(initialValue, combine(previousValue, T element)) { | 263 E reduce(E combine(E value, T element)) { |
268 return IterableMixinWorkaround.reduce(this, initialValue, combine); | 264 return IterableMixinWorkaround.reduce(this, combine); |
269 } | 265 } |
270 | 266 |
271 fold(initialValue, combine(previousValue, T element)) { | 267 fold(initialValue, combine(previousValue, T element)) { |
272 return IterableMixinWorkaround.fold(this, initialValue, combine); | 268 return IterableMixinWorkaround.fold(this, initialValue, combine); |
273 } | 269 } |
274 | 270 |
275 Iterable<T> where(bool f(T element)) { | 271 Iterable<T> where(bool f(T element)) { |
276 return IterableMixinWorkaround.where(this, f); | 272 return IterableMixinWorkaround.where(this, f); |
277 } | 273 } |
278 | 274 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 343 } |
348 | 344 |
349 Set<T> toSet() { | 345 Set<T> toSet() { |
350 return new Set<T>.from(this); | 346 return new Set<T>.from(this); |
351 } | 347 } |
352 | 348 |
353 Map<int, T> asMap() { | 349 Map<int, T> asMap() { |
354 return IterableMixinWorkaround.asMapList(this); | 350 return IterableMixinWorkaround.asMapList(this); |
355 } | 351 } |
356 } | 352 } |
OLD | NEW |