| 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.collection; | 5 part of dart.collection; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This class provides default implementations for Iterables (including Lists). | 8 * This class provides default implementations for Iterables (including Lists). |
| 9 * | 9 * |
| 10 * Once Dart receives Mixins it will be replaced with mixin classes. | 10 * Once Dart receives Mixins it will be replaced with mixin classes. |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 348 } |
| 349 | 349 |
| 350 static Iterable reversedList(List l) { | 350 static Iterable reversedList(List l) { |
| 351 return new ReversedListIterable(l); | 351 return new ReversedListIterable(l); |
| 352 } | 352 } |
| 353 | 353 |
| 354 static void sortList(List l, int compare(a, b)) { | 354 static void sortList(List l, int compare(a, b)) { |
| 355 if (compare == null) compare = Comparable.compare; | 355 if (compare == null) compare = Comparable.compare; |
| 356 Sort.sort(l, compare); | 356 Sort.sort(l, compare); |
| 357 } | 357 } |
| 358 |
| 359 static Map<int, dynamic> asMapList(List l) { |
| 360 return new ListMapView(l); |
| 361 } |
| 358 } | 362 } |
| 359 | 363 |
| 360 class Collections { | 364 class Collections { |
| 361 static String collectionToString(Collection c) | 365 static String collectionToString(Collection c) |
| 362 => ToString.collectionToString(c); | 366 => ToString.collectionToString(c); |
| 363 } | 367 } |
| 364 | 368 |
| 365 /** | 369 /** |
| 366 * An unmodifiable [List] view of another List. | 370 * An unmodifiable [List] view of another List. |
| 367 * | 371 * |
| 368 * The source of the elements may be a [List] or any [Iterable] with | 372 * The source of the elements may be a [List] or any [Iterable] with |
| 369 * efficient [Iterable.length] and [Iterable.elementAt]. | 373 * efficient [Iterable.length] and [Iterable.elementAt]. |
| 370 */ | 374 */ |
| 371 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { | 375 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { |
| 372 Iterable<E> _source; | 376 Iterable<E> _source; |
| 373 /** Create an unmodifiable list backed by [source]. */ | 377 /** Create an unmodifiable list backed by [source]. */ |
| 374 UnmodifiableListView(Iterable<E> source) : _source = source; | 378 UnmodifiableListView(Iterable<E> source) : _source = source; |
| 375 int get length => _source.length; | 379 int get length => _source.length; |
| 376 E operator[](int index) => _source.elementAt(index); | 380 E operator[](int index) => _source.elementAt(index); |
| 377 } | 381 } |
| OLD | NEW |