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 |
10 // Set. | 10 // Set. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 * | 103 * |
104 * If [equals] is [identical], this creates an identity set. Any hashCode | 104 * If [equals] is [identical], this creates an identity set. Any hashCode |
105 * is compatible with [identical], and it applies to all objects, so | 105 * is compatible with [identical], and it applies to all objects, so |
106 * [hashCode] and [isValidKey] can safely be omitted. | 106 * [hashCode] and [isValidKey] can safely be omitted. |
107 */ | 107 */ |
108 external factory HashSet({ bool equals(E e1, E e2), | 108 external factory HashSet({ bool equals(E e1, E e2), |
109 int hashCode(E e), | 109 int hashCode(E e), |
110 bool isValidKey(potentialKey) }); | 110 bool isValidKey(potentialKey) }); |
111 | 111 |
112 /** | 112 /** |
| 113 * Creates an unordered identity-based set. |
| 114 * |
| 115 * Effectively a shorthand for: |
| 116 * |
| 117 * new HashSet(equals: identical, hashCode: identityHashCodeOf) |
| 118 */ |
| 119 external factory HashSet.identity(); |
| 120 |
| 121 /** |
113 * Create a hash set containing the elements of [iterable]. | 122 * Create a hash set containing the elements of [iterable]. |
114 * | 123 * |
115 * Creates a hash set as by `new HashSet<E>()` and adds each element of | 124 * Creates a hash set as by `new HashSet<E>()` and adds each element of |
116 * `iterable` to this set in the order they are iterated. | 125 * `iterable` to this set in the order they are iterated. |
117 */ | 126 */ |
118 factory HashSet.from(Iterable<E> iterable) { | 127 factory HashSet.from(Iterable<E> iterable) { |
119 return new HashSet<E>()..addAll(iterable); | 128 return new HashSet<E>()..addAll(iterable); |
120 } | 129 } |
121 } | 130 } |
OLD | NEW |