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 /** | 5 /** |
6 * Delegating wrappers for [Iterable], [List], [Set], [Queue] and [Map]. | 6 * Delegating wrappers for [Iterable], [List], [Set], [Queue] and [Map]. |
7 * | 7 * |
8 * Also adds unmodifiable views for `Set` and `Map`, and a fixed length | 8 * Also adds unmodifiable views for `Set` and `Map`, and a fixed length |
9 * view for `List`. The unmodifable list view from `dart:collection` is exported | 9 * view for `List`. The unmodifable list view from `dart:collection` is exported |
10 * as well, just for completeness. | 10 * as well, just for completeness. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void clear() { | 227 void clear() { |
228 _setBase.clear(); | 228 _setBase.clear(); |
229 } | 229 } |
230 | 230 |
231 bool containsAll(Iterable<Object> other) => _setBase.containsAll(other); | 231 bool containsAll(Iterable<Object> other) => _setBase.containsAll(other); |
232 | 232 |
233 Set<E> difference(Set<E> other) => _setBase.difference(other); | 233 Set<E> difference(Set<E> other) => _setBase.difference(other); |
234 | 234 |
235 Set<E> intersection(Set<Object> other) => _setBase.intersection(other); | 235 Set<E> intersection(Set<Object> other) => _setBase.intersection(other); |
236 | 236 |
237 E lookup(E element) => _setBase.lookup(element); | 237 E lookup(Object element) => _setBase.lookup(element); |
238 | 238 |
239 bool remove(Object value) => _setBase.remove(value); | 239 bool remove(Object value) => _setBase.remove(value); |
240 | 240 |
241 void removeAll(Iterable<Object> elements) { | 241 void removeAll(Iterable<Object> elements) { |
242 _setBase.removeAll(elements); | 242 _setBase.removeAll(elements); |
243 } | 243 } |
244 | 244 |
245 void removeWhere(bool test(E element)) { | 245 void removeWhere(bool test(E element)) { |
246 _setBase.removeWhere(test); | 246 _setBase.removeWhere(test); |
247 } | 247 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 * Returns a new set which is the intersection between [this] and [other]. | 511 * Returns a new set which is the intersection between [this] and [other]. |
512 * | 512 * |
513 * That is, the returned set contains all the elements of this [Set] that are | 513 * That is, the returned set contains all the elements of this [Set] that are |
514 * also elements of [other] according to `other.contains`. | 514 * also elements of [other] according to `other.contains`. |
515 * | 515 * |
516 * Note that the returned set will use the default equality operation, which | 516 * Note that the returned set will use the default equality operation, which |
517 * may be different than the equality operation [this] uses. | 517 * may be different than the equality operation [this] uses. |
518 */ | 518 */ |
519 Set<V> intersection(Set<Object> other) => where(other.contains).toSet(); | 519 Set<V> intersection(Set<Object> other) => where(other.contains).toSet(); |
520 | 520 |
521 V lookup(V element) => _baseMap[_keyForValue(element)]; | 521 V lookup(Object element) => _baseMap[_keyForValue(element)]; |
522 | 522 |
523 bool remove(Object value) { | 523 bool remove(Object value) { |
524 if (value != null && value is! V) return false; | 524 if (value != null && value is! V) return false; |
525 var key = _keyForValue(value); | 525 var key = _keyForValue(value); |
526 if (!_baseMap.containsKey(key)) return false; | 526 if (!_baseMap.containsKey(key)) return false; |
527 _baseMap.remove(key); | 527 _baseMap.remove(key); |
528 return true; | 528 return true; |
529 } | 529 } |
530 | 530 |
531 void removeAll(Iterable<Object> elements) => elements.forEach(remove); | 531 void removeAll(Iterable<Object> elements) => elements.forEach(remove); |
(...skipping 29 matching lines...) Expand all Loading... |
561 * Returns a new set which contains all the elements of [this] and [other]. | 561 * Returns a new set which contains all the elements of [this] and [other]. |
562 * | 562 * |
563 * That is, the returned set contains all the elements of this [Set] and all | 563 * That is, the returned set contains all the elements of this [Set] and all |
564 * the elements of [other]. | 564 * the elements of [other]. |
565 * | 565 * |
566 * Note that the returned set will use the default equality operation, which | 566 * Note that the returned set will use the default equality operation, which |
567 * may be different than the equality operation [this] uses. | 567 * may be different than the equality operation [this] uses. |
568 */ | 568 */ |
569 Set<V> union(Set<V> other) => toSet()..addAll(other); | 569 Set<V> union(Set<V> other) => toSet()..addAll(other); |
570 } | 570 } |
OLD | NEW |