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 static final int _classId = (new _GrowableObjectArray(0))._cid; | 6 static final int _classId = (new _GrowableObjectArray(0))._cid; |
7 | 7 |
8 void insert(int index, T element) { | 8 void insert(int index, T element) { |
9 if (index < 0 || index > length) { | 9 if (index < 0 || index > length) { |
10 throw new RangeError.range(index, 0, length); | 10 throw new RangeError.range(index, 0, length); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 void clear() { | 329 void clear() { |
330 this.length = 0; | 330 this.length = 0; |
331 } | 331 } |
332 | 332 |
333 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this); | 333 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this); |
334 | 334 |
335 void sort([int compare(T a, T b)]) { | 335 void sort([int compare(T a, T b)]) { |
336 IterableMixinWorkaround.sortList(this, compare); | 336 IterableMixinWorkaround.sortList(this, compare); |
337 } | 337 } |
338 | 338 |
| 339 void shuffle() { |
| 340 IterableMixinWorkaround.shuffleList(this); |
| 341 } |
| 342 |
339 String toString() { | 343 String toString() { |
340 return IterableMixinWorkaround.toStringIterable(this, '[', ']'); | 344 return IterableMixinWorkaround.toStringIterable(this, '[', ']'); |
341 } | 345 } |
342 | 346 |
343 Iterator<T> get iterator { | 347 Iterator<T> get iterator { |
344 return new ListIterator<T>(this); | 348 return new ListIterator<T>(this); |
345 } | 349 } |
346 | 350 |
347 List<T> toList({ bool growable: true }) { | 351 List<T> toList({ bool growable: true }) { |
348 return new List<T>.from(this, growable: growable); | 352 return new List<T>.from(this, growable: growable); |
349 } | 353 } |
350 | 354 |
351 Set<T> toSet() { | 355 Set<T> toSet() { |
352 return new Set<T>.from(this); | 356 return new Set<T>.from(this); |
353 } | 357 } |
354 | 358 |
355 Map<int, T> asMap() { | 359 Map<int, T> asMap() { |
356 return IterableMixinWorkaround.asMapList(this); | 360 return IterableMixinWorkaround.asMapList(this); |
357 } | 361 } |
358 } | 362 } |
OLD | NEW |