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