public abstract class AbstractSet<E>
- Object
- AbstractCollection<E>
- AbstractSet
ImplementsCollection<E>, Iterable<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().
Constructors
protected AbstractSet() | Constructs a new instance of this AbstractSet. |
Methods
public boolean equals(Object object) | Compares the specified object to this Set and returns true if they are equal. |
public int hashCode() | Returns the hash code for this set. |
public boolean removeAll(Collection<?> collection) | Removes all occurrences in this collection which are contained in the specified collection. |
Inherited methods
From AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, retainAll, size, toString, toArray, toArray
From Collection
Constructor details
AbstractSet
protected AbstractSet()Constructs a new instance of this AbstractSet.
Method details
equals
public boolean equals(Object object)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.
Parameters
objectObject- the object to compare with this set.
Returns
true if the specified object is equal to this set,
false otherwiseSee also
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.
Returns
the hash code of this set.
See also
removeAll
public boolean removeAll(Collection<?> collection)Removes all occurrences in this collection which are contained in the
specified collection.
Parameters
collectionCollection<?>- the collection of objects to remove.
Returns
true if this collection was modified, false
otherwise.Throws
UnsupportedOperationException- if removing from this collection is not supported.