public abstract class AbstractConcurrentSet<E> extends Object implements Set<E>
Set
interface to minimize the effort
required to implement this interface. Unlike AbstractSet
skeletal implementation,
this one is more forgiving to concurrent modifications of this set during implemented bulk operations.Modifier | Constructor and Description |
---|---|
protected |
AbstractConcurrentSet()
Sole constructor; for invocation by subclass constructors, typically implicit.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addAll(Collection<? extends E> c)
Adds all of the elements in the specified collection into this set and
returns true if this operation has increased the size of this set.
|
void |
clear()
Removes all of the elements from this set.
|
boolean |
containsAll(Collection<?> c)
Tests if this set contains all of the elements in the specified collection.
|
boolean |
equals(Object o)
Compares the specified object with this set for equality.
|
int |
hashCode()
Returns the hash code value for this set.
|
boolean |
isEmpty()
Tests if this set has no elements.
|
boolean |
removeAll(Collection<?> c)
Removes all of the elements in the specified collection from this set and
returns true if this operation has decreased the size of this set.
|
boolean |
retainAll(Collection<?> c)
Retains only the elements in this set that are contained in the specified collection.
|
Object[] |
toArray()
Returns an array containing all of the elements in this set.
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the elements in this set whose runtime type
is that of the specified array.
|
String |
toString()
Returns a string representation of this set.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
parallelStream, removeIf, stream
protected AbstractConcurrentSet()
public void clear()
This implementation iterates all elements of this set and removes them using Iterator.remove()
method.
public boolean isEmpty()
This implementation checks emptiness using Set.size()
method.
public Object[] toArray()
Collection.toArray()
method.
This implementation iterates all elements of this set and adds them into the array.
public <T> T[] toArray(T[] a)
Collection.toArray(Object[])
method.
This implementation iterates all elements of this set and adds them into the array.
public boolean containsAll(Collection<?> c)
This implementation iterates all elements of specified collection and tests
them one-by-one using contains(element)
method.
containsAll
in interface Collection<E>
containsAll
in interface Set<E>
public boolean addAll(Collection<? extends E> c)
This implementation iterates all elements of specified collection and adds
them one-by-one using add(element)
method.
public boolean removeAll(Collection<?> c)
This implementation compares size of specified collection with the size of this set, then iterates smaller collection and removes elements that need to be removed.
public boolean retainAll(Collection<?> c)
This implementation iterates all elements of this set, checks if they are contained in
the specified collection, and removes them if needed using Iterator.remove()
method.
public boolean equals(Object o)
Set.equals(Object)
method.
This implementation compares size of specified set with the size of this set and then
checks element containment using containsAll((Set)o)
method.
public int hashCode()
Set.hashCode()
method.
This implementation iterates all elements of this set and adds their hash codes.
Copyright © 2002–2025 Devexperts LLC. All rights reserved.