1 *java.util.AbstractSet* *AbstractSet* This class provides a skeletal implementat
3 public abstract class AbstractSet
4 extends |java.util.AbstractCollection|
5 implements |java.util.Set|
7 |java.util.AbstractSet_Description|
8 |java.util.AbstractSet_Fields|
9 |java.util.AbstractSet_Constructors|
10 |java.util.AbstractSet_Methods|
12 ================================================================================
14 *java.util.AbstractSet_Constructors*
15 |java.util.AbstractSet()|Sole constructor.
17 *java.util.AbstractSet_Methods*
18 |java.util.AbstractSet.equals(Object)|Compares the specified object with this s
19 |java.util.AbstractSet.hashCode()|Returns the hash code value for this set.
20 |java.util.AbstractSet.removeAll(Collection)|Removes from this set all of its e
22 *java.util.AbstractSet_Description*
24 This class provides a skeletal implementation of the Set interface to minimize
25 the effort required to implement this interface.
27 The process of implementing a set by extending this class is identical to that
28 of implementing a Collection by extending AbstractCollection, except that all
29 of the methods and constructors in subclasses of this class must obey the
30 additional constraints imposed by the Set interface (for instance, the add
31 method must not permit addition of multiple instances of an object to a set).
33 Note that this class does not override any of the implementations from the
34 AbstractCollection class. It merely adds implementations for equals and
37 This class is a member of the <a href="/../guide/collections/index.html"> Java
38 Collections Framework.
41 *java.util.AbstractSet()*
43 protected AbstractSet()
45 Sole constructor. (For invocation by subclass constructors, typically
49 *java.util.AbstractSet.equals(Object)*
51 public boolean equals(java.lang.Object o)
53 Compares the specified object with this set for equality. Returns true if the
54 given object is also a set, the two sets have the same size, and every member
55 of the given set is contained in this set. This ensures that the equals method
56 works properly across different implementations of the Set interface.
58 This implementation first checks if the specified object is this set; if so it
59 returns true. Then, it checks if the specified object is a set whose size is
60 identical to the size of this set; if not, it returns false. If so, it returns
61 containsAll((Collection) o).
63 o - Object to be compared for equality with this set.
65 Returns: true if the specified object is equal to this set.
66 *java.util.AbstractSet.hashCode()*
70 Returns the hash code value for this set. The hash code of a set is defined to
71 be the sum of the hash codes of the elements in the set. This ensures that
72 s1.equals(s2) implies that s1.hashCode()==s2.hashCode() for any two sets s1 and
73 s2, as required by the general contract of Object.hashCode.
75 This implementation enumerates over the set, calling the hashCode method on
76 each element in the collection, and adding up the results.
79 Returns: the hash code value for this set.
80 *java.util.AbstractSet.removeAll(Collection)*
82 public boolean removeAll(java.util.Collection c)
84 Removes from this set all of its elements that are contained in the specified
85 collection (optional operation).
87 This implementation determines which is the smaller of this set and the
88 specified collection, by invoking the size method on each. If this set has
89 fewer elements, then the implementation iterates over this set, checking each
90 element returned by the iterator in turn to see if it is contained in the
91 specified collection. If it is so contained, it is removed from this set with
92 the iterator's remove method. If the specified collection has fewer elements,
93 then the implementation iterates over the specified collection, removing from
94 this set each element returned by the iterator, using this set's remove method.
96 Note that this implementation will throw an UnsupportedOperationException if
97 the iterator returned by the iterator method does not implement the remove
100 c - elements to be removed from this set.
102 Returns: true if this set changed as a result of the call.