Chromium Code Reviews| 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 String toString() => IterableMixinWorkaround.toStringIterable(this); |
|
floitsch
2013/07/08 16:12:34
Add TODO too.
zarah
2013/07/08 16:57:46
Done.
| |
| 57 } | 58 } |
| 58 | 59 |
| 59 /** | 60 /** |
| 60 * A [HashSet] is a hash-table based [Set] implementation. | 61 * A [HashSet] is a hash-table based [Set] implementation. |
| 61 * | 62 * |
| 62 * The elements of a `HashSet` must have consistent [Object.operator==] | 63 * The elements of a `HashSet` must have consistent [Object.operator==] |
| 63 * and [Object.hashCode] implementations. This means that the `==` operator | 64 * and [Object.hashCode] implementations. This means that the `==` operator |
| 64 * must define a stable equivalence relation on the elements (reflexive, | 65 * must define a stable equivalence relation on the elements (reflexive, |
| 65 * anti-symmetric, transitive, and consistent over time), and that `hashCode` | 66 * anti-symmetric, transitive, and consistent over time), and that `hashCode` |
| 66 * must be the same for objects that are considered equal by `==`. | 67 * 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); | 99 external void removeAll(Iterable<Object> objectsToRemove); |
| 99 | 100 |
| 100 external void removeWhere(bool test(E element)); | 101 external void removeWhere(bool test(E element)); |
| 101 | 102 |
| 102 external void retainWhere(bool test(E element)); | 103 external void retainWhere(bool test(E element)); |
| 103 | 104 |
| 104 external void clear(); | 105 external void clear(); |
| 105 | 106 |
| 106 Set<E> _newSet() => new HashSet<E>(); | 107 Set<E> _newSet() => new HashSet<E>(); |
| 107 } | 108 } |
| OLD | NEW |