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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 314 } |
315 | 315 |
316 static Iterable map(Iterable iterable, f(var element)) { | 316 static Iterable map(Iterable iterable, f(var element)) { |
317 return new MappedIterable(iterable, f); | 317 return new MappedIterable(iterable, f); |
318 } | 318 } |
319 | 319 |
320 static Iterable mapList(List list, f(var element)) { | 320 static Iterable mapList(List list, f(var element)) { |
321 return new MappedListIterable(list, f); | 321 return new MappedListIterable(list, f); |
322 } | 322 } |
323 | 323 |
| 324 static List mappedByList(List list, f(var element)) { |
| 325 // This is currently a List as well as an Iterable. |
| 326 return new MappedList(list, f); |
| 327 } |
| 328 |
324 static Iterable expand(Iterable iterable, Iterable f(var element)) { | 329 static Iterable expand(Iterable iterable, Iterable f(var element)) { |
325 return new ExpandIterable(iterable, f); | 330 return new ExpandIterable(iterable, f); |
326 } | 331 } |
327 | 332 |
328 static Iterable takeList(List list, int n) { | 333 static Iterable takeList(List list, int n) { |
329 // The generic type is currently lost. It will be fixed with mixins. | 334 // The generic type is currently lost. It will be fixed with mixins. |
330 // This is currently a List as well as an Iterable. | 335 // This is currently a List as well as an Iterable. |
331 return new SubListIterable(list, 0, n); | 336 return new SubListIterable(list, 0, n); |
332 } | 337 } |
333 | 338 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 static String joinList(List list, [String separator]) | 467 static String joinList(List list, [String separator]) |
463 => IterableMixinWorkaround.joinList(list, separator); | 468 => IterableMixinWorkaround.joinList(list, separator); |
464 | 469 |
465 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 470 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
466 @deprecated | 471 @deprecated |
467 static Iterable where(Iterable iterable, bool f(var element)) | 472 static Iterable where(Iterable iterable, bool f(var element)) |
468 => IterableMixinWorkaround.where(iterable, f); | 473 => IterableMixinWorkaround.where(iterable, f); |
469 | 474 |
470 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 475 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
471 @deprecated | 476 @deprecated |
| 477 static List mappedByList(List list, f(var element)) |
| 478 => IterableMixinWorkaround.mappedByList(list, f); |
| 479 |
| 480 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
| 481 @deprecated |
472 static Iterable takeList(List list, int n) | 482 static Iterable takeList(List list, int n) |
473 => IterableMixinWorkaround.takeList(list, n); | 483 => IterableMixinWorkaround.takeList(list, n); |
474 | 484 |
475 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 485 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
476 @deprecated | 486 @deprecated |
477 static Iterable takeWhile(Iterable iterable, bool test(var value)) | 487 static Iterable takeWhile(Iterable iterable, bool test(var value)) |
478 => IterableMixinWorkaround.takeWhile(iterable, test); | 488 => IterableMixinWorkaround.takeWhile(iterable, test); |
479 | 489 |
480 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 490 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
481 @deprecated | 491 @deprecated |
(...skipping 15 matching lines...) Expand all Loading... |
497 * The source of the elements may be a [List] or any [Iterable] with | 507 * The source of the elements may be a [List] or any [Iterable] with |
498 * efficient [Iterable.length] and [Iterable.elementAt]. | 508 * efficient [Iterable.length] and [Iterable.elementAt]. |
499 */ | 509 */ |
500 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { | 510 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { |
501 Iterable<E> _source; | 511 Iterable<E> _source; |
502 /** Create an unmodifiable list backed by [source]. */ | 512 /** Create an unmodifiable list backed by [source]. */ |
503 UnmodifiableListView(Iterable<E> source) : _source = source; | 513 UnmodifiableListView(Iterable<E> source) : _source = source; |
504 int get length => _source.length; | 514 int get length => _source.length; |
505 E operator[](int index) => _source.elementAt(index); | 515 E operator[](int index) => _source.elementAt(index); |
506 } | 516 } |
OLD | NEW |