| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.collection; | 5 part of dart.collection; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Abstract implementation of a list. | 8 * Abstract implementation of a list. |
| 9 * | 9 * |
| 10 * `ListBase` can be used as a base class for implementing the `List` interface. | 10 * `ListBase` can be used as a base class for implementing the `List` interface. |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 if (length == 0) { | 302 if (length == 0) { |
| 303 throw IterableElementError.noElement(); | 303 throw IterableElementError.noElement(); |
| 304 } | 304 } |
| 305 E result = this[length - 1]; | 305 E result = this[length - 1]; |
| 306 length--; | 306 length--; |
| 307 return result; | 307 return result; |
| 308 } | 308 } |
| 309 | 309 |
| 310 void sort([int compare(E a, E b)]) { | 310 void sort([int compare(E a, E b)]) { |
| 311 if (compare == null) { | 311 if (compare == null) { |
| 312 Sort.sort(this, Comparable.compare); | 312 Sort.sort(this, (a, b) => (a as Comparable).compareTo(b)); |
| 313 } else { | 313 } else { |
| 314 Sort.sort(this, compare); | 314 Sort.sort(this, compare); |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 | 317 |
| 318 void shuffle([Random random]) { | 318 void shuffle([Random random]) { |
| 319 if (random == null) random = new Random(); | 319 if (random == null) random = new Random(); |
| 320 int length = this.length; | 320 int length = this.length; |
| 321 while (length > 1) { | 321 while (length > 1) { |
| 322 int pos = random.nextInt(length); | 322 int pos = random.nextInt(length); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 for (E element in iterable) { | 507 for (E element in iterable) { |
| 508 this[index++] = element; | 508 this[index++] = element; |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 } | 511 } |
| 512 | 512 |
| 513 Iterable<E> get reversed => new ReversedListIterable<E>(this); | 513 Iterable<E> get reversed => new ReversedListIterable<E>(this); |
| 514 | 514 |
| 515 String toString() => IterableBase.iterableToFullString(this, '[', ']'); | 515 String toString() => IterableBase.iterableToFullString(this, '[', ']'); |
| 516 } | 516 } |
| OLD | NEW |