| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This class is the public interface of a set. A set is a collection | 8 * This class is the public interface of a set. A set is a collection |
| 9 * without duplicates. | 9 * without duplicates. |
| 10 */ | 10 */ |
| 11 abstract class Set<E> extends Collection<E> { | 11 abstract class Set<E> extends Iterable<E> { |
| 12 factory Set() => new HashSet<E>(); | 12 factory Set() => new HashSet<E>(); |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * Creates a [Set] that contains all elements of [other]. | 15 * Creates a [Set] that contains all elements of [other]. |
| 16 */ | 16 */ |
| 17 factory Set.from(Iterable<E> other) => new HashSet<E>.from(other); | 17 factory Set.from(Iterable<E> other) => new HashSet<E>.from(other); |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * Returns true if [value] is in the set. | 20 * Returns true if [value] is in the set. |
| 21 */ | 21 */ |
| 22 bool contains(E value); | 22 bool contains(E value); |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * Adds [value] into the set. The method has no effect if | 25 * Adds [value] into the set. The method has no effect if |
| 26 * [value] was already in the set. | 26 * [value] was already in the set. |
| 27 */ | 27 */ |
| 28 void add(E value); | 28 void add(E value); |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * Adds all of [elements] to this Set. |
| 32 * |
| 33 * Equivalent to adding each element in [elements] using [add], |
| 34 * but some collections may be able to optimize it. |
| 35 */ |
| 36 void addAll(Iterable<E> elements); |
| 37 |
| 38 /** |
| 31 * Removes [value] from the set. Returns true if [value] was | 39 * Removes [value] from the set. Returns true if [value] was |
| 32 * in the set. Returns false otherwise. The method has no effect | 40 * in the set. Returns false otherwise. The method has no effect |
| 33 * if [value] value was not in the set. | 41 * if [value] value was not in the set. |
| 34 */ | 42 */ |
| 35 bool remove(Object value); | 43 bool remove(Object value); |
| 36 | 44 |
| 37 /** | 45 /** |
| 38 * Returns true if [other] contains all the elements of this Set. | 46 * Removes all of [elements] from this set. |
| 39 * | |
| 40 * *Deprecated*. Use `other.containsAll(thisSet)` instead if [other] | |
| 41 * is a Set, and convert `other` to a Set if it isn't. | |
| 42 */ | 47 */ |
| 43 @deprecated | 48 void removeAll(Iterable elements); |
| 44 bool isSubsetOf(Iterable<E> other); | 49 |
| 50 /** |
| 51 * Removes all elements of this set that are not |
| 52 * in [elements]. |
| 53 */ |
| 54 void retainAll(Iterable elements); |
| 55 |
| 56 /** |
| 57 * Removes all elements of this set that satisfy [test]. |
| 58 */ |
| 59 void removeWhere(bool test(E element)); |
| 60 |
| 61 /** |
| 62 * Removes all elements of this set that fail to satisfy [test]. |
| 63 */ |
| 64 void retainWhere(bool test(E element)); |
| 45 | 65 |
| 46 /** | 66 /** |
| 47 * Returns true if this Set contains all the elements of [other]. | 67 * Returns true if this Set contains all the elements of [other]. |
| 48 */ | 68 */ |
| 49 bool containsAll(Iterable<E> other); | 69 bool containsAll(Iterable<E> other); |
| 50 | 70 |
| 51 /** | 71 /** |
| 52 * Returns a new set which is the intersection between this set and [other]. | 72 * Returns a new set which is the intersection between this set and [other]. |
| 53 */ | 73 */ |
| 54 Set<E> intersection(Set<E> other); | 74 Set<E> intersection(Set<E> other); |
| 55 | 75 |
| 56 /** | 76 /** |
| 57 * Returns a new set which contains all the elements of this set and [other]. | 77 * Returns a new set which contains all the elements of this set and [other]. |
| 58 */ | 78 */ |
| 59 Set<E> union(Set<E> other); | 79 Set<E> union(Set<E> other); |
| 60 | 80 |
| 61 /** | 81 /** |
| 62 * Returns a new set with the the elements of this that are not in [other]. | 82 * Returns a new set with the the elements of this that are not in [other]. |
| 63 */ | 83 */ |
| 64 Set<E> difference(Set<E> other); | 84 Set<E> difference(Set<E> other); |
| 65 | 85 |
| 66 /** | 86 /** |
| 67 * Removes all elements in the set. | 87 * Removes all elements in the set. |
| 68 */ | 88 */ |
| 69 void clear(); | 89 void clear(); |
| 70 } | 90 } |
| OLD | NEW |