| 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 * A `Set` is a collection of elements where each element can occur only once. | 8 * A `Set` is a collection of elements where each element can occur only once. |
| 9 * | 9 * |
| 10 * That is, for each object of the element type, the object is either considered | 10 * That is, for each object of the element type, the object is either considered |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 * | 35 * |
| 36 * The created `Set` is a [HashSet]. As such, it considers elements that | 36 * The created `Set` is a [HashSet]. As such, it considers elements that |
| 37 * are equal (using `==`) to be undistinguishable, and requires them to | 37 * are equal (using `==`) to be undistinguishable, and requires them to |
| 38 * have a compatible [Object.hashCode] implementation. | 38 * have a compatible [Object.hashCode] implementation. |
| 39 */ | 39 */ |
| 40 factory Set.from(Iterable<E> other) => new HashSet<E>.from(other); | 40 factory Set.from(Iterable<E> other) => new HashSet<E>.from(other); |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Returns true if [value] is in the set. | 43 * Returns true if [value] is in the set. |
| 44 */ | 44 */ |
| 45 bool contains(E value); | 45 bool contains(Object value); |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Adds [value] into the set. | 48 * Adds [value] into the set. |
| 49 * | 49 * |
| 50 * The method has no effect if [value] is already in the set. | 50 * The method has no effect if [value] is already in the set. |
| 51 */ | 51 */ |
| 52 void add(E value); | 52 void add(E value); |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Adds all of [elements] to this Set. | 55 * Adds all of [elements] to this Set. |
| 56 * | 56 * |
| 57 * Equivalent to adding each element in [elements] using [add], | 57 * Equivalent to adding each element in [elements] using [add], |
| 58 * but some collections may be able to optimize it. | 58 * but some collections may be able to optimize it. |
| 59 */ | 59 */ |
| 60 void addAll(Iterable<E> elements); | 60 void addAll(Iterable<E> elements); |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Removes [value] from the set. Returns true if [value] was | 63 * Removes [value] from the set. Returns true if [value] was |
| 64 * in the set. Returns false otherwise. The method has no effect | 64 * in the set. Returns false otherwise. The method has no effect |
| 65 * if [value] value was not in the set. | 65 * if [value] value was not in the set. |
| 66 */ | 66 */ |
| 67 bool remove(Object value); | 67 bool remove(Object value); |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Removes each element of [elements] from this set. | 70 * Removes each element of [elements] from this set. |
| 71 */ | 71 */ |
| 72 void removeAll(Iterable elements); | 72 void removeAll(Iterable<Object> elements); |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * Removes all elements of this set that are not elements in [elements]. | 75 * Removes all elements of this set that are not elements in [elements]. |
| 76 */ | 76 */ |
| 77 void retainAll(Iterable elements); | 77 void retainAll(Iterable<Object> elements); |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * Removes all elements of this set that satisfy [test]. | 80 * Removes all elements of this set that satisfy [test]. |
| 81 */ | 81 */ |
| 82 void removeWhere(bool test(E element)); | 82 void removeWhere(bool test(E element)); |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Removes all elements of this set that fail to satisfy [test]. | 85 * Removes all elements of this set that fail to satisfy [test]. |
| 86 */ | 86 */ |
| 87 void retainWhere(bool test(E element)); | 87 void retainWhere(bool test(E element)); |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * Returns whether this Set contains all the elements of [other]. | 90 * Returns whether this Set contains all the elements of [other]. |
| 91 */ | 91 */ |
| 92 bool containsAll(Iterable<E> other); | 92 bool containsAll(Iterable<Object> other); |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Returns a new set which is the intersection between this set and [other]. | 95 * Returns a new set which is the intersection between this set and [other]. |
| 96 * | 96 * |
| 97 * That is, the returned set contains all the elements of this `Set` that | 97 * That is, the returned set contains all the elements of this `Set` that |
| 98 * are also elements of [other]. | 98 * are also elements of [other]. |
| 99 */ | 99 */ |
| 100 Set<E> intersection(Set<E> other); | 100 Set<E> intersection(Set<Object> other); |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * Returns a new set which contains all the elements of this set and [other]. | 103 * Returns a new set which contains all the elements of this set and [other]. |
| 104 * | 104 * |
| 105 * That is, the returned set contains all the elements of this `Set` and | 105 * That is, the returned set contains all the elements of this `Set` and |
| 106 * all the elements of [other]. | 106 * all the elements of [other]. |
| 107 */ | 107 */ |
| 108 Set<E> union(Set<E> other); | 108 Set<E> union(Set<E> other); |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * Returns a new set with the the elements of this that are not in [other]. | 111 * Returns a new set with the the elements of this that are not in [other]. |
| 112 * | 112 * |
| 113 * That is, the returned set contains all the elements of this `Set` that | 113 * That is, the returned set contains all the elements of this `Set` that |
| 114 * are not elements of [other]. | 114 * are not elements of [other]. |
| 115 */ | 115 */ |
| 116 Set<E> difference(Set<E> other); | 116 Set<E> difference(Set<E> other); |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * Removes all elements in the set. | 119 * Removes all elements in the set. |
| 120 */ | 120 */ |
| 121 void clear(); | 121 void clear(); |
| 122 } | 122 } |
| OLD | NEW |