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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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)) { | 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, 0, null); | 321 return new MappedListIterable(list, f); |
322 } | 322 } |
323 | 323 |
324 static List mappedByList(List list, f(var element)) { | 324 static List mappedByList(List list, f(var element)) { |
325 // This is currently a List as well as an Iterable. | 325 // This is currently a List as well as an Iterable. |
326 return new MappedList(list, f); | 326 return new MappedList(list, f); |
327 } | 327 } |
328 | 328 |
329 static Iterable expand(Iterable iterable, Iterable f(var element)) { | 329 static Iterable expand(Iterable iterable, Iterable f(var element)) { |
330 return new ExpandIterable(iterable, f); | 330 return new ExpandIterable(iterable, f); |
331 } | 331 } |
332 | 332 |
333 static Iterable takeList(List list, int n) { | 333 static Iterable takeList(List list, int n) { |
334 // 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. |
335 // This is currently a List as well as an Iterable. | 335 // This is currently a List as well as an Iterable. |
336 return new ListView(list, 0, n); | 336 return new SubListIterable(list, 0, n); |
337 } | 337 } |
338 | 338 |
339 static Iterable takeWhile(Iterable iterable, bool test(var value)) { | 339 static Iterable takeWhile(Iterable iterable, bool test(var value)) { |
340 // The generic type is currently lost. It will be fixed with mixins. | 340 // The generic type is currently lost. It will be fixed with mixins. |
341 return new TakeWhileIterable(iterable, test); | 341 return new TakeWhileIterable(iterable, test); |
342 } | 342 } |
343 | 343 |
344 static Iterable skipList(List list, int n) { | 344 static Iterable skipList(List list, int n) { |
345 // The generic type is currently lost. It will be fixed with mixins. | 345 // The generic type is currently lost. It will be fixed with mixins. |
346 // This is currently a List as well as an Iterable. | 346 // This is currently a List as well as an Iterable. |
347 return new ListView(list, n, null); | 347 return new SubListIterable(list, n, null); |
348 } | 348 } |
349 | 349 |
350 static Iterable skipWhile(Iterable iterable, bool test(var value)) { | 350 static Iterable skipWhile(Iterable iterable, bool test(var value)) { |
351 // The generic type is currently lost. It will be fixed with mixins. | 351 // The generic type is currently lost. It will be fixed with mixins. |
352 return new SkipWhileIterable(iterable, test); | 352 return new SkipWhileIterable(iterable, test); |
353 } | 353 } |
354 | 354 |
355 static List reversedList(List l) { | 355 static Iterable reversedList(List l) { |
356 return new ReversedListView(l, 0, null); | 356 return new ReversedListIterable(l); |
357 } | 357 } |
358 | 358 |
359 static void sortList(List l, int compare(a, b)) { | 359 static void sortList(List l, int compare(a, b)) { |
360 if (compare == null) compare = Comparable.compare; | 360 if (compare == null) compare = Comparable.compare; |
361 Sort.sort(l, compare); | 361 Sort.sort(l, compare); |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 /** | 365 /** |
366 * The [Collections] class implements static methods useful when | 366 * The [Collections] class implements static methods useful when |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 => IterableMixinWorkaround.skipList(list, n); | 493 => IterableMixinWorkaround.skipList(list, n); |
494 | 494 |
495 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ | 495 /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/ |
496 @deprecated | 496 @deprecated |
497 static Iterable skipWhile(Iterable iterable, bool test(var value)) | 497 static Iterable skipWhile(Iterable iterable, bool test(var value)) |
498 => IterableMixinWorkaround.skipWhile(iterable, test); | 498 => IterableMixinWorkaround.skipWhile(iterable, test); |
499 | 499 |
500 static String collectionToString(Collection c) | 500 static String collectionToString(Collection c) |
501 => ToString.collectionToString(c); | 501 => ToString.collectionToString(c); |
502 } | 502 } |
OLD | NEW |