| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 buffer.add("${list[i]}"); | 306 buffer.add("${list[i]}"); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 return buffer.toString(); | 309 return buffer.toString(); |
| 310 } | 310 } |
| 311 | 311 |
| 312 static Iterable where(Iterable iterable, bool f(var element)) { | 312 static Iterable where(Iterable iterable, bool f(var element)) { |
| 313 return new WhereIterable(iterable, f); | 313 return new WhereIterable(iterable, f); |
| 314 } | 314 } |
| 315 | 315 |
| 316 static Iterable map(Iterable iterable, f(var element)) { |
| 317 return new MappedIterable(iterable, f); |
| 318 } |
| 319 |
| 316 static List mappedByList(List list, f(var element)) { | 320 static List mappedByList(List list, f(var element)) { |
| 321 // This is currently a List as well as an Iterable. |
| 317 return new MappedList(list, f); | 322 return new MappedList(list, f); |
| 318 } | 323 } |
| 319 | 324 |
| 320 static List takeList(List list, int n) { | 325 static Iterable takeList(List list, int n) { |
| 321 // The generic type is currently lost. It will be fixed with mixins. | 326 // The generic type is currently lost. It will be fixed with mixins. |
| 327 // This is currently a List as well as an Iterable. |
| 322 return new ListView(list, 0, n); | 328 return new ListView(list, 0, n); |
| 323 } | 329 } |
| 324 | 330 |
| 325 static Iterable takeWhile(Iterable iterable, bool test(var value)) { | 331 static Iterable takeWhile(Iterable iterable, bool test(var value)) { |
| 326 // The generic type is currently lost. It will be fixed with mixins. | 332 // The generic type is currently lost. It will be fixed with mixins. |
| 327 return new TakeWhileIterable(iterable, test); | 333 return new TakeWhileIterable(iterable, test); |
| 328 } | 334 } |
| 329 | 335 |
| 330 static List skipList(List list, int n) { | 336 static Iterable skipList(List list, int n) { |
| 331 // The generic type is currently lost. It will be fixed with mixins. | 337 // The generic type is currently lost. It will be fixed with mixins. |
| 338 // This is currently a List as well as an Iterable. |
| 332 return new ListView(list, n, null); | 339 return new ListView(list, n, null); |
| 333 } | 340 } |
| 334 | 341 |
| 335 static Iterable skipWhile(Iterable iterable, bool test(var value)) { | 342 static Iterable skipWhile(Iterable iterable, bool test(var value)) { |
| 336 // The generic type is currently lost. It will be fixed with mixins. | 343 // The generic type is currently lost. It will be fixed with mixins. |
| 337 return new SkipWhileIterable(iterable, test); | 344 return new SkipWhileIterable(iterable, test); |
| 338 } | 345 } |
| 339 | 346 |
| 340 static List reversedList(List l) { | 347 static List reversedList(List l) { |
| 341 return new ReversedListView(l, 0, null); | 348 return new ReversedListView(l, 0, null); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 443 |
| 437 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 444 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
| 438 static Iterable where(Iterable iterable, bool f(var element)) | 445 static Iterable where(Iterable iterable, bool f(var element)) |
| 439 => IterableMixinWorkaround.where(iterable, f); | 446 => IterableMixinWorkaround.where(iterable, f); |
| 440 | 447 |
| 441 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 448 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
| 442 static List mappedByList(List list, f(var element)) | 449 static List mappedByList(List list, f(var element)) |
| 443 => IterableMixinWorkaround.mappedByList(list, f); | 450 => IterableMixinWorkaround.mappedByList(list, f); |
| 444 | 451 |
| 445 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 452 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
| 446 static List takeList(List list, int n) | 453 static Iterable takeList(List list, int n) |
| 447 => IterableMixinWorkaround.takeList(list, n); | 454 => IterableMixinWorkaround.takeList(list, n); |
| 448 | 455 |
| 449 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 456 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
| 450 static Iterable takeWhile(Iterable iterable, bool test(var value)) | 457 static Iterable takeWhile(Iterable iterable, bool test(var value)) |
| 451 => IterableMixinWorkaround.takeWhile(iterable, test); | 458 => IterableMixinWorkaround.takeWhile(iterable, test); |
| 452 | 459 |
| 453 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 460 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
| 454 static List skipList(List list, int n) | 461 static Iterable skipList(List list, int n) |
| 455 => IterableMixinWorkaround.skipList(list, n); | 462 => IterableMixinWorkaround.skipList(list, n); |
| 456 | 463 |
| 457 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 464 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
| 458 static Iterable skipWhile(Iterable iterable, bool test(var value)) | 465 static Iterable skipWhile(Iterable iterable, bool test(var value)) |
| 459 => IterableMixinWorkaround.skipWhile(iterable, test); | 466 => IterableMixinWorkaround.skipWhile(iterable, test); |
| 460 | 467 |
| 461 static String collectionToString(Collection c) | 468 static String collectionToString(Collection c) |
| 462 => ToString.collectionToString(c); | 469 => ToString.collectionToString(c); |
| 463 } | 470 } |
| OLD | NEW |