| 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 SetBase<E> { | 8 abstract class _HashSetBase<E> extends SetBase<E> { |
| 9 | 9 |
| 10 // The following two methods override the ones in SetBase. | 10 // The following two methods override the ones in SetBase. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 * If [isValidKey] is omitted, it defaults to testing if the object is an | 66 * If [isValidKey] is omitted, it defaults to testing if the object is an |
| 67 * [E] instance. | 67 * [E] instance. |
| 68 * | 68 * |
| 69 * If you supply one of [equals] and [hashCode], | 69 * If you supply one of [equals] and [hashCode], |
| 70 * you should generally also to supply the other. | 70 * you should generally also to supply the other. |
| 71 * An example would be using [identical] and [identityHashCode], | 71 * An example would be using [identical] and [identityHashCode], |
| 72 * which is equivalent to using the shorthand [LinkedSet.identity]). | 72 * which is equivalent to using the shorthand [LinkedSet.identity]). |
| 73 */ | 73 */ |
| 74 factory HashSet({ bool equals(E e1, E e2), | 74 factory HashSet({ bool equals(E e1, E e2), |
| 75 int hashCode(E e), | 75 int hashCode(E e), |
| 76 bool isValidKey(potentialKey) }) { | 76 bool isValidKey(Object potentialKey) }) { |
| 77 if (isValidKey == null) { | 77 if (isValidKey == null) { |
| 78 if (hashCode == null) { | 78 if (hashCode == null) { |
| 79 if (equals == null) { | 79 if (equals == null) { |
| 80 return new _HashSet<E>(); | 80 return new _HashSet<E>(); |
| 81 } | 81 } |
| 82 hashCode = _defaultHashCode; | 82 hashCode = _defaultHashCode; |
| 83 } else { | 83 } else { |
| 84 if (identical(identityHashCode, hashCode) && | 84 if (identical(identityHashCode, hashCode) && |
| 85 identical(identical, equals)) { | 85 identical(identical, equals)) { |
| 86 return new _IdentityHashSet<E>(); | 86 return new _IdentityHashSet<E>(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 130 } |
| 131 | 131 |
| 132 /** | 132 /** |
| 133 * Provides an iterator that iterates over the elements of this set. | 133 * Provides an iterator that iterates over the elements of this set. |
| 134 * | 134 * |
| 135 * The order of iteration is unspecified, | 135 * The order of iteration is unspecified, |
| 136 * but consistent between changes to the set. | 136 * but consistent between changes to the set. |
| 137 */ | 137 */ |
| 138 Iterator<E> get iterator; | 138 Iterator<E> get iterator; |
| 139 } | 139 } |
| OLD | NEW |