| 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 List<E> sublist(int start, [int end]) { | 328 List<E> sublist(int start, [int end]) { |
| 329 int listLength = this.length; | 329 int listLength = this.length; |
| 330 if (end == null) end = listLength; | 330 if (end == null) end = listLength; |
| 331 RangeError.checkValidRange(start, end, listLength); | 331 RangeError.checkValidRange(start, end, listLength); |
| 332 int length = end - start; | 332 int length = end - start; |
| 333 List<E> result = new List<E>()..length = length; | 333 List<E> result = new List<E>()..length = length; |
| 334 for (int i = 0; i < length; i++) { | 334 for (int i = 0; i < length; i++) { |
| 335 result[i] = this[start + i]; | 335 result[i] = this[start + i]; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 for (E element in iterable) { | 495 for (E element in iterable) { |
| 496 this[index++] = element; | 496 this[index++] = element; |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 Iterable<E> get reversed => new ReversedListIterable<E>(this); | 501 Iterable<E> get reversed => new ReversedListIterable<E>(this); |
| 502 | 502 |
| 503 String toString() => IterableBase.iterableToFullString(this, '[', ']'); | 503 String toString() => IterableBase.iterableToFullString(this, '[', ']'); |
| 504 } | 504 } |
| OLD | NEW |