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 class LinkedHashSet<E> extends Collection<E> implements Set<E> { | 7 class LinkedHashSet<E> extends Collection<E> implements Set<E> { |
8 static const int _INITIAL_CAPACITY = 8; | 8 static const int _INITIAL_CAPACITY = 8; |
9 _LinkedHashTable<E> _table; | 9 _LinkedHashTable<E> _table; |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 void retainWhere(bool test(E element)) { | 122 void retainWhere(bool test(E element)) { |
123 _filterWhere(test, false); | 123 _filterWhere(test, false); |
124 } | 124 } |
125 | 125 |
126 void clear() { | 126 void clear() { |
127 _table._clear(); | 127 _table._clear(); |
128 } | 128 } |
129 | 129 |
130 // Set. | 130 // Set. |
131 bool isSubsetOf(Collection<E> other) { | 131 bool isSubsetOf(Set<E> other) { |
132 // Deprecated, and using old signature. | 132 return IterableMixinWorkaround.isSubsetOfSet(this, other); |
133 Set otherSet; | |
134 if (other is Set) { | |
135 otherSet = other; | |
136 } else { | |
137 otherSet = other.toSet(); | |
138 } | |
139 return IterableMixinWorkaround.setContainsAll(otherSet, this); | |
140 } | 133 } |
141 | 134 |
142 bool containsAll(Iterable<E> other) { | 135 bool containsAll(Set<E> other) { |
143 return IterableMixinWorkaround.setContainsAll(this, other); | 136 return IterableMixinWorkaround.isSubsetOfSet(other, this); |
144 } | 137 } |
145 | 138 |
146 Set<E> intersection(Set<E> other) { | 139 Set<E> intersection(Set<E> other) { |
147 return IterableMixinWorkaround.setIntersection( | 140 return IterableMixinWorkaround.setIntersection( |
148 this, other, new LinkedHashSet<E>()); | 141 this, other, new LinkedHashSet<E>()); |
149 } | 142 } |
150 | 143 |
151 Set<E> union(Set<E> other) { | 144 Set<E> union(Set<E> other) { |
152 return IterableMixinWorkaround.setUnion( | 145 return IterableMixinWorkaround.setUnion( |
153 this, other, new LinkedHashSet<E>()); | 146 this, other, new LinkedHashSet<E>()); |
154 } | 147 } |
155 | 148 |
156 Set<E> difference(Set<E> other) { | 149 Set<E> difference(Set<E> other) { |
157 return IterableMixinWorkaround.setDifference( | 150 return IterableMixinWorkaround.setDifference( |
158 this, other, new LinkedHashSet<E>()); | 151 this, other, new LinkedHashSet<E>()); |
159 } | 152 } |
160 | 153 |
161 String toString() => Collections.collectionToString(this); | 154 String toString() => Collections.collectionToString(this); |
162 } | 155 } |
OLD | NEW |