Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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.dev; | 5 part of dart._collection.dev; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An [Iterable] for classes that have efficient [length] and [elementAt]. | 8 * An [Iterable] for classes that have efficient [length] and [elementAt]. |
| 9 * | 9 * |
| 10 * All other methods are implemented in terms of [length] and [elementAt], | 10 * All other methods are implemented in terms of [length] and [elementAt], |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 } | 687 } |
| 688 | 688 |
| 689 /** | 689 /** |
| 690 * This class provides default implementations for Iterables (including Lists). | 690 * This class provides default implementations for Iterables (including Lists). |
| 691 * | 691 * |
| 692 * The uses of this class will be replaced by mixins. | 692 * The uses of this class will be replaced by mixins. |
| 693 */ | 693 */ |
| 694 class IterableMixinWorkaround { | 694 class IterableMixinWorkaround { |
| 695 static bool contains(Iterable iterable, var element) { | 695 static bool contains(Iterable iterable, var element) { |
| 696 for (final e in iterable) { | 696 for (final e in iterable) { |
| 697 if (element == e) return true; | 697 if (e == element) return true; |
|
Lasse Reichstein Nielsen
2013/06/26 08:26:59
Excellent!
| |
| 698 } | 698 } |
| 699 return false; | 699 return false; |
| 700 } | 700 } |
| 701 | 701 |
| 702 static void forEach(Iterable iterable, void f(o)) { | 702 static void forEach(Iterable iterable, void f(o)) { |
| 703 for (final e in iterable) { | 703 for (final e in iterable) { |
| 704 f(e); | 704 f(e); |
| 705 } | 705 } |
| 706 } | 706 } |
| 707 | 707 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1054 | 1054 |
| 1055 static Set setDifference(Set set, Set other, Set result) { | 1055 static Set setDifference(Set set, Set other, Set result) { |
| 1056 for (var element in set) { | 1056 for (var element in set) { |
| 1057 if (!other.contains(element)) { | 1057 if (!other.contains(element)) { |
| 1058 result.add(element); | 1058 result.add(element); |
| 1059 } | 1059 } |
| 1060 } | 1060 } |
| 1061 return result; | 1061 return result; |
| 1062 } | 1062 } |
| 1063 } | 1063 } |
| OLD | NEW |