Package org.jppf.utils.collections
Class ConcurrentHashSet<E>
java.lang.Object
org.jppf.utils.collections.ConcurrentHashSet<E>
- Type Parameters:
E- the type of objects in the set.
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
A concurrent
set implementation backed by a ConcurrentHashMap.- Author:
- Laurent Cohen
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, empty set with a default initial capacity of 16, a load factor of 0.75 and a concurrency level of 16.ConcurrentHashSet(int initialCapacity) Create a new, empty set with the specified initial capacity, a load factor of 0.75 and a concurrency level of 16ConcurrentHashSet(int initialCapacity, float loadFactor) Create a new, empty set with the specified initial capacity, load factor and a concurrency level of 16.ConcurrentHashSet(int initialCapacity, float loadFactor, int concurrencyLevel) Create a new, empty map with the specified initial capacity, load factor and concurrency level. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> c) voidclear()booleanbooleancontainsAll(Collection<?> c) booleanisEmpty()iterator()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Constructor Details
-
ConcurrentHashSet
public ConcurrentHashSet()Create a new, empty set with a default initial capacity of 16, a load factor of 0.75 and a concurrency level of 16. -
ConcurrentHashSet
public ConcurrentHashSet(int initialCapacity) Create a new, empty set with the specified initial capacity, a load factor of 0.75 and a concurrency level of 16- Parameters:
initialCapacity- the initial capacity.
-
ConcurrentHashSet
public ConcurrentHashSet(int initialCapacity, float loadFactor) Create a new, empty set with the specified initial capacity, load factor and a concurrency level of 16.- Parameters:
initialCapacity- the initial capacity.loadFactor- the load factor threshold, used to control resizing.
-
ConcurrentHashSet
public ConcurrentHashSet(int initialCapacity, float loadFactor, int concurrencyLevel) Create a new, empty map with the specified initial capacity, load factor and concurrency level.- Parameters:
initialCapacity- the initial capacity.loadFactor- the load factor threshold, used to control resizing.concurrencyLevel- the estimated number of concurrently updating threads.
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
iterator
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
add
-
remove
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>
-
addAll
-
retainAll
-
removeAll
-
clear
public void clear()
-