Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: sdk/lib/collection/hash_set.dart

Issue 2754013002: Format all dart: library files (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
10 // The following two methods override the ones in SetBase. 9 // The following two methods override the ones in SetBase.
11 // It's possible to be more efficient if we have a way to create an empty 10 // It's possible to be more efficient if we have a way to create an empty
12 // set of the correct type. 11 // set of the correct type.
13 12
14 Set<E> difference(Set<Object> other) { 13 Set<E> difference(Set<Object> other) {
15 Set<E> result = _newSet(); 14 Set<E> result = _newSet();
16 for (var element in this) { 15 for (var element in this) {
17 if (!other.contains(element)) result.add(element); 16 if (!other.contains(element)) result.add(element);
18 } 17 }
19 return result; 18 return result;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 * If neither `equals`, `hashCode`, nor `isValidKey` is provided, 88 * If neither `equals`, `hashCode`, nor `isValidKey` is provided,
90 * the default `isValidKey` instead accepts all values. 89 * the default `isValidKey` instead accepts all values.
91 * The default equality and hashcode operations are assumed to work on all 90 * The default equality and hashcode operations are assumed to work on all
92 * objects. 91 * objects.
93 * 92 *
94 * Likewise, if `equals` is [identical], `hashCode` is [identityHashCode] 93 * Likewise, if `equals` is [identical], `hashCode` is [identityHashCode]
95 * and `isValidKey` is omitted, the resulting set is identity based, 94 * and `isValidKey` is omitted, the resulting set is identity based,
96 * and the `isValidKey` defaults to accepting all keys. 95 * and the `isValidKey` defaults to accepting all keys.
97 * Such a map can be created directly using [HashSet.identity]. 96 * Such a map can be created directly using [HashSet.identity].
98 */ 97 */
99 external factory HashSet({bool equals(E e1, E e2), 98 external factory HashSet(
100 int hashCode(E e), 99 {bool equals(E e1, E e2),
101 bool isValidKey(potentialKey)}); 100 int hashCode(E e),
101 bool isValidKey(potentialKey)});
102 102
103 /** 103 /**
104 * Creates an unordered identity-based set. 104 * Creates an unordered identity-based set.
105 * 105 *
106 * Effectively a shorthand for: 106 * Effectively a shorthand for:
107 * 107 *
108 * new HashSet<E>(equals: identical, 108 * new HashSet<E>(equals: identical,
109 * hashCode: identityHashCode) 109 * hashCode: identityHashCode)
110 */ 110 */
111 external factory HashSet.identity(); 111 external factory HashSet.identity();
(...skipping 24 matching lines...) Expand all
136 } 136 }
137 137
138 /** 138 /**
139 * Provides an iterator that iterates over the elements of this set. 139 * Provides an iterator that iterates over the elements of this set.
140 * 140 *
141 * The order of iteration is unspecified, 141 * The order of iteration is unspecified,
142 * but consistent between changes to the set. 142 * but consistent between changes to the set.
143 */ 143 */
144 Iterator<E> get iterator; 144 Iterator<E> get iterator;
145 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698