[all packages]
[package java.util]
[class hierarchy]
[index]
java.lang.Object | +----java.util.AbstractCollection<A> | +----java.util.AbstractSet<A>
public abstract class AbstractSet<A> extends AbstractCollection<A> implements Set<A>
The process of implementing a Set by extending this class is identical to that of implementing a Collection by extending AbstractCollection, except that all of the methods and constructors in subclasses of this class must obey the additional constraints imposed by the Set interface (for instance, the add method must not permit addition of multiple intances of an object to a Set).
Note that this class does not override any of the implementations from abstractCollection. It merely adds implementations for equals and hashCode.
public AbstractSet();
equals
public boolean equals(Object o);
This implementation first checks if the specified Object is this Set;
if so it returns true. Then, it checks if the specified Object is
a Set whose size is identical to the size of this Set; if not, it
it returns false. If so, it returns
containsAll((Collection) o)
.
public int hashCode();
s1.equals(s2)
implies that
s1.hashCode()==s2.hashCode()
for any two Sets
s1
and s2
, as required by the general
contract of Object.hashCode.
This implementation enumerates over the Set, calling hashCode on each element in the Collection, and adding up the results.
[all packages]
[package java.util]
[class hierarchy]
[index]