| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 * instead of just repeatedly calling remove. | 67 * instead of just repeatedly calling remove. |
| 68 */ | 68 */ |
| 69 static void removeAllList(Collection collection, Iterable elementsToRemove) { | 69 static void removeAllList(Collection collection, Iterable elementsToRemove) { |
| 70 Set setToRemove; | 70 Set setToRemove; |
| 71 // Assume contains is efficient on a Set. | 71 // Assume contains is efficient on a Set. |
| 72 if (elementsToRemove is Set) { | 72 if (elementsToRemove is Set) { |
| 73 setToRemove = elementsToRemove; | 73 setToRemove = elementsToRemove; |
| 74 } else { | 74 } else { |
| 75 setToRemove = elementsToRemove.toSet(); | 75 setToRemove = elementsToRemove.toSet(); |
| 76 } | 76 } |
| 77 collection.removeMatching(setToRemve.contains); | 77 collection.removeMatching(setToRemove.contains); |
| 78 } | 78 } |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Simple implemenation for [Collection.retainAll]. | 81 * Simple implemenation for [Collection.retainAll]. |
| 82 * | 82 * |
| 83 * This implementation assumes that [Collecton.retainMatching] on [collection] | 83 * This implementation assumes that [Collecton.retainMatching] on [collection] |
| 84 * is efficient. | 84 * is efficient. |
| 85 */ | 85 */ |
| 86 static void retainAll(Collection collection, Iterable elementsToRetain) { | 86 static void retainAll(Collection collection, Iterable elementsToRetain) { |
| 87 Set lookup; | 87 Set lookup; |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 * Returns true if the specified collection contains the specified object | 516 * Returns true if the specified collection contains the specified object |
| 517 * reference. | 517 * reference. |
| 518 */ | 518 */ |
| 519 static _containsRef(Collection c, Object ref) { | 519 static _containsRef(Collection c, Object ref) { |
| 520 for (var e in c) { | 520 for (var e in c) { |
| 521 if (identical(e, ref)) return true; | 521 if (identical(e, ref)) return true; |
| 522 } | 522 } |
| 523 return false; | 523 return false; |
| 524 } | 524 } |
| 525 } | 525 } |
| OLD | NEW |