Chromium Code Reviews| 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 part of dart._interceptors; | 5 part of dart._interceptors; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The interceptor class for [List]. The compiler recognizes this | 8 * The interceptor class for [List]. The compiler recognizes this |
| 9 * class as an interceptor, and changes references to [:this:] to | 9 * class as an interceptor, and changes references to [:this:] to |
| 10 * actually use the receiver of the method, which is generated as an extra | 10 * actually use the receiver of the method, which is generated as an extra |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 if (!test(element)) return false; | 456 if (!test(element)) return false; |
| 457 if (this.length != end) throw new ConcurrentModificationError(this); | 457 if (this.length != end) throw new ConcurrentModificationError(this); |
| 458 } | 458 } |
| 459 return true; | 459 return true; |
| 460 } | 460 } |
| 461 | 461 |
| 462 Iterable<E> get reversed => new ReversedListIterable<E>(this); | 462 Iterable<E> get reversed => new ReversedListIterable<E>(this); |
| 463 | 463 |
| 464 void sort([int compare(E a, E b)]) { | 464 void sort([int compare(E a, E b)]) { |
| 465 checkMutable('sort'); | 465 checkMutable('sort'); |
| 466 Sort.sort(this, compare == null ? Comparable.compare : compare); | 466 if (compare == null) { |
| 467 Sort.sort(this, (a, b) => (a as Comparable).compareTo(b)); | |
|
vsm
2016/09/06 21:26:07
Maybe:
(a, b) => Comparable.compare(a, b);
?
Bob Nystrom
2016/09/09 00:14:21
Done.
| |
| 468 } else { | |
| 469 Sort.sort(this, compare); | |
| 470 } | |
| 467 } | 471 } |
| 468 | 472 |
| 469 void shuffle([Random random]) { | 473 void shuffle([Random random]) { |
| 470 checkMutable('shuffle'); | 474 checkMutable('shuffle'); |
| 471 if (random == null) random = new Random(); | 475 if (random == null) random = new Random(); |
| 472 int length = this.length; | 476 int length = this.length; |
| 473 while (length > 1) { | 477 while (length > 1) { |
| 474 int pos = random.nextInt(length); | 478 int pos = random.nextInt(length); |
| 475 length -= 1; | 479 length -= 1; |
| 476 var tmp = this[length]; | 480 var tmp = this[length]; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 | 618 |
| 615 if (_index >= length) { | 619 if (_index >= length) { |
| 616 _current = null; | 620 _current = null; |
| 617 return false; | 621 return false; |
| 618 } | 622 } |
| 619 _current = _iterable[_index]; | 623 _current = _iterable[_index]; |
| 620 _index++; | 624 _index++; |
| 621 return true; | 625 return true; |
| 622 } | 626 } |
| 623 } | 627 } |
| OLD | NEW |