Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: sdk/lib/collection/collections.dart

Issue 12286004: Unbreak pub: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | sdk/lib/core/iterable.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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); 321 return new MappedListIterable(list, f, 0, null);
322 }
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);
322 } 327 }
323 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 ListView(list, 0, n);
332 } 337 }
333 338
334 static Iterable takeWhile(Iterable iterable, bool test(var value)) { 339 static Iterable takeWhile(Iterable iterable, bool test(var value)) {
335 // 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.
336 return new TakeWhileIterable(iterable, test); 341 return new TakeWhileIterable(iterable, test);
337 } 342 }
338 343
339 static Iterable skipList(List list, int n) { 344 static Iterable skipList(List list, int n) {
340 // 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.
341 // This is currently a List as well as an Iterable. 346 // This is currently a List as well as an Iterable.
342 return new SubListIterable(list, n, null); 347 return new ListView(list, n, null);
343 } 348 }
344 349
345 static Iterable skipWhile(Iterable iterable, bool test(var value)) { 350 static Iterable skipWhile(Iterable iterable, bool test(var value)) {
346 // 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.
347 return new SkipWhileIterable(iterable, test); 352 return new SkipWhileIterable(iterable, test);
348 } 353 }
349 354
350 static Iterable reversedList(List l) { 355 static List reversedList(List l) {
351 return new ReversedListIterable(l); 356 return new ReversedListView(l, 0, null);
352 } 357 }
353 358
354 static void sortList(List l, int compare(a, b)) { 359 static void sortList(List l, int compare(a, b)) {
355 if (compare == null) compare = Comparable.compare; 360 if (compare == null) compare = Comparable.compare;
356 Sort.sort(l, compare); 361 Sort.sort(l, compare);
357 } 362 }
358 } 363 }
359 364
360 /** 365 /**
361 * The [Collections] class implements static methods useful when 366 * The [Collections] class implements static methods useful when
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | sdk/lib/core/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698