Class AbstractSet<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
- All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
An AbstractSet is an abstract implementation of the Set interface. This
implementation does not support adding. A subclass must implement the
abstract methods iterator() and size().
- Since:
- 1.2
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a new instance of this AbstractSet. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares the specified object to this Set and returns true if they are equal.inthashCode()Returns the hash code for this set.booleanremoveAll(Collection<?> collection) Removes all occurrences in this collection which are contained in the specified collection.
-
Constructor Details
-
AbstractSet
protected AbstractSet()Constructs a new instance of this AbstractSet.
-
-
Method Details
-
equals
Compares the specified object to this Set and returns true if they are equal. The object must be an instance of Set and contain the same objects. -
hashCode
public int hashCode()Returns the hash code for this set. Two set which are equal must return the same value. This implementation calculates the hash code by adding each element's hash code. -
removeAll
Removes all occurrences in this collection which are contained in the specified collection.- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceSet<E>- Overrides:
removeAllin classAbstractCollection<E>- Parameters:
collection- the collection of objects to remove.- Returns:
trueif this collection was modified,falseotherwise.- Throws:
UnsupportedOperationException- if removing from this collection is not supported.
-