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