| 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 // Set. | 9 // Set. |
| 10 bool containsAll(Iterable<E> other) { | 10 bool containsAll(Iterable<Object> other) { |
| 11 for (E object in other) { | 11 for (Object object in other) { |
| 12 if (!this.contains(object)) return false; | 12 if (!this.contains(object)) return false; |
| 13 } | 13 } |
| 14 return true; | 14 return true; |
| 15 } | 15 } |
| 16 | 16 |
| 17 /** Create a new Set of the same type as this. */ | 17 /** Create a new Set of the same type as this. */ |
| 18 Set _newSet(); | 18 Set _newSet(); |
| 19 | 19 |
| 20 Set<E> intersection(Set<E> other) { | 20 Set<E> intersection(Set<Object> other) { |
| 21 Set<E> result = _newSet(); | 21 Set<E> result = _newSet(); |
| 22 if (other.length < this.length) { | 22 if (other.length < this.length) { |
| 23 for (E element in other) { | 23 for (var element in other) { |
| 24 if (this.contains(element)) result.add(element); | 24 if (this.contains(element)) result.add(element); |
| 25 } | 25 } |
| 26 } else { | 26 } else { |
| 27 for (E element in this) { | 27 for (E element in this) { |
| 28 if (other.contains(element)) result.add(element); | 28 if (other.contains(element)) result.add(element); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 return result; | 31 return result; |
| 32 } | 32 } |
| 33 | 33 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 external bool contains(Object object); | 89 external bool contains(Object object); |
| 90 | 90 |
| 91 // Set. | 91 // Set. |
| 92 external void add(E element); | 92 external void add(E element); |
| 93 | 93 |
| 94 external void addAll(Iterable<E> objects); | 94 external void addAll(Iterable<E> objects); |
| 95 | 95 |
| 96 external bool remove(Object object); | 96 external bool remove(Object object); |
| 97 | 97 |
| 98 external void removeAll(Iterable objectsToRemove); | 98 external void removeAll(Iterable<Object> objectsToRemove); |
| 99 | 99 |
| 100 external void removeWhere(bool test(E element)); | 100 external void removeWhere(bool test(E element)); |
| 101 | 101 |
| 102 external void retainWhere(bool test(E element)); | 102 external void retainWhere(bool test(E element)); |
| 103 | 103 |
| 104 external void clear(); | 104 external void clear(); |
| 105 | 105 |
| 106 Set<E> _newSet() => new HashSet<E>(); | 106 Set<E> _newSet() => new HashSet<E>(); |
| 107 } | 107 } |
| OLD | NEW |