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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 while (length > 1) { | 315 while (length > 1) { |
316 int pos = random.nextInt(length); | 316 int pos = random.nextInt(length); |
317 length -= 1; | 317 length -= 1; |
318 var tmp = this[length]; | 318 var tmp = this[length]; |
319 this[length] = this[pos]; | 319 this[length] = this[pos]; |
320 this[pos] = tmp; | 320 this[pos] = tmp; |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
324 Map<int, E> asMap() { | 324 Map<int, E> asMap() { |
325 return new ListMapView(this); | 325 return new ListMapView<E>(this); |
326 } | 326 } |
327 | 327 |
328 void _rangeCheck(int start, int end) { | 328 void _rangeCheck(int start, int end) { |
329 if (start < 0 || start > this.length) { | 329 if (start < 0 || start > this.length) { |
330 throw new RangeError.range(start, 0, this.length); | 330 throw new RangeError.range(start, 0, this.length); |
331 } | 331 } |
332 if (end < start || end > this.length) { | 332 if (end < start || end > this.length) { |
333 throw new RangeError.range(end, start, this.length); | 333 throw new RangeError.range(end, start, this.length); |
334 } | 334 } |
335 } | 335 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 for (E element in iterable) { | 508 for (E element in iterable) { |
509 this[index++] = element; | 509 this[index++] = element; |
510 } | 510 } |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 Iterable<E> get reversed => new ReversedListIterable<E>(this); | 514 Iterable<E> get reversed => new ReversedListIterable<E>(this); |
515 | 515 |
516 String toString() => IterableBase.iterableToFullString(this, '[', ']'); | 516 String toString() => IterableBase.iterableToFullString(this, '[', ']'); |
517 } | 517 } |
OLD | NEW |