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 _GrowableList<T> implements List<T> { | 5 class _GrowableList<T> implements List<T> { |
6 static final int _classId = (new _GrowableList(0))._cid; | 6 static final int _classId = (new _GrowableList(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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this); | 320 Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this); |
321 | 321 |
322 void sort([int compare(T a, T b)]) { | 322 void sort([int compare(T a, T b)]) { |
323 IterableMixinWorkaround.sortList(this, compare); | 323 IterableMixinWorkaround.sortList(this, compare); |
324 } | 324 } |
325 | 325 |
326 void shuffle([Random random]) { | 326 void shuffle([Random random]) { |
327 IterableMixinWorkaround.shuffleList(this, random); | 327 IterableMixinWorkaround.shuffleList(this, random); |
328 } | 328 } |
329 | 329 |
330 String toString() { | 330 String toString() => ListBase.listToString(this); |
331 return IterableMixinWorkaround.toStringIterable(this, '[', ']'); | |
332 } | |
333 | 331 |
334 Iterator<T> get iterator { | 332 Iterator<T> get iterator { |
335 return new ListIterator<T>(this); | 333 return new ListIterator<T>(this); |
336 } | 334 } |
337 | 335 |
338 List<T> toList({ bool growable: true }) { | 336 List<T> toList({ bool growable: true }) { |
339 return new List<T>.from(this, growable: growable); | 337 return new List<T>.from(this, growable: growable); |
340 } | 338 } |
341 | 339 |
342 Set<T> toSet() { | 340 Set<T> toSet() { |
343 return new Set<T>.from(this); | 341 return new Set<T>.from(this); |
344 } | 342 } |
345 | 343 |
346 Map<int, T> asMap() { | 344 Map<int, T> asMap() { |
347 return IterableMixinWorkaround.asMapList(this); | 345 return IterableMixinWorkaround.asMapList(this); |
348 } | 346 } |
349 } | 347 } |
OLD | NEW |