public abstract class AbstractSet<E>

  1. Object
  2. AbstractCollection<E>
  3. AbstractSet

ImplementsCollection<E>, Iterable<E>, Set<E>

Known subtypesHashSet, TreeSet

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

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

object Object
the object to compare with this set.

Returns

true if the specified object is equal to this set, false otherwise

See 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

collection Collection<?>
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.