| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** Common parts of [HashSet] and [LinkedHashSet] implementations. */ | 7 /** Common parts of [HashSet] and [LinkedHashSet] implementations. */ |
| 8 abstract class _HashSetBase<E> extends IterableBase<E> implements Set<E> { | 8 abstract class _HashSetBase<E> extends IterableBase<E> implements Set<E> { |
| 9 |
| 9 // Set. | 10 // Set. |
| 10 bool containsAll(Iterable<Object> other) { | 11 bool containsAll(Iterable<Object> other) { |
| 11 for (Object object in other) { | 12 for (Object object in other) { |
| 12 if (!this.contains(object)) return false; | 13 if (!this.contains(object)) return false; |
| 13 } | 14 } |
| 14 return true; | 15 return true; |
| 15 } | 16 } |
| 16 | 17 |
| 17 /** Create a new Set of the same type as this. */ | 18 /** Create a new Set of the same type as this. */ |
| 18 Set _newSet(); | 19 Set _newSet(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 46 void retainAll(Iterable objectsToRetain) { | 47 void retainAll(Iterable objectsToRetain) { |
| 47 Set retainSet; | 48 Set retainSet; |
| 48 if (objectsToRetain is Set) { | 49 if (objectsToRetain is Set) { |
| 49 retainSet = objectsToRetain; | 50 retainSet = objectsToRetain; |
| 50 } else { | 51 } else { |
| 51 retainSet = objectsToRetain.toSet(); | 52 retainSet = objectsToRetain.toSet(); |
| 52 } | 53 } |
| 53 retainWhere(retainSet.contains); | 54 retainWhere(retainSet.contains); |
| 54 } | 55 } |
| 55 | 56 |
| 56 String toString() => ToString.iterableToString(this); | 57 // TODO(zarah) Remove this, and let it be inherited by IterableBase |
| 58 String toString() => IterableMixinWorkaround.toStringIterable(this); |
| 57 } | 59 } |
| 58 | 60 |
| 59 /** | 61 /** |
| 60 * A [HashSet] is a hash-table based [Set] implementation. | 62 * A [HashSet] is a hash-table based [Set] implementation. |
| 61 * | 63 * |
| 62 * The elements of a `HashSet` must have consistent [Object.operator==] | 64 * The elements of a `HashSet` must have consistent [Object.operator==] |
| 63 * and [Object.hashCode] implementations. This means that the `==` operator | 65 * and [Object.hashCode] implementations. This means that the `==` operator |
| 64 * must define a stable equivalence relation on the elements (reflexive, | 66 * must define a stable equivalence relation on the elements (reflexive, |
| 65 * anti-symmetric, transitive, and consistent over time), and that `hashCode` | 67 * anti-symmetric, transitive, and consistent over time), and that `hashCode` |
| 66 * must be the same for objects that are considered equal by `==`. | 68 * must be the same for objects that are considered equal by `==`. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 external void removeAll(Iterable<Object> objectsToRemove); | 100 external void removeAll(Iterable<Object> objectsToRemove); |
| 99 | 101 |
| 100 external void removeWhere(bool test(E element)); | 102 external void removeWhere(bool test(E element)); |
| 101 | 103 |
| 102 external void retainWhere(bool test(E element)); | 104 external void retainWhere(bool test(E element)); |
| 103 | 105 |
| 104 external void clear(); | 106 external void clear(); |
| 105 | 107 |
| 106 Set<E> _newSet() => new HashSet<E>(); | 108 Set<E> _newSet() => new HashSet<E>(); |
| 107 } | 109 } |
| OLD | NEW |