Class ConcurrentHashSet<E>
- java.lang.Object
 - 
- java.util.AbstractCollection<E>
 - 
- java.util.AbstractSet<E>
 - 
- org.infinispan.commons.util.concurrent.ConcurrentHashSet<E>
 
 
 
 
- 
- All Implemented Interfaces:
 Serializable,Iterable<E>,Collection<E>,Set<E>
public class ConcurrentHashSet<E> extends AbstractSet<E> implements Serializable
A simple Set implementation backed by aConcurrentHashMapto deal with the fact that the JDK does not have a proper concurrent Set implementation that uses efficient lock striping. Note that values are stored as keys in the underlying Map, with a static dummy object as value.- Since:
 - 4.0
 - Author:
 - Manik Surtani
 - See Also:
 - Serialized Form
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected ConcurrentMap<E,Object>map 
- 
Constructor Summary
Constructors Constructor Description ConcurrentHashSet()ConcurrentHashSet(int concurrencyLevel)ConcurrentHashSet(int initSize, float loadFactor, int concurrencyLevel)Params passed in to the underlying CHM. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E o)booleanaddAll(Collection<? extends E> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)booleanisEmpty()Iterator<E>iterator()booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()Object[]toArray()<T> T[]toArray(T[] a)- 
Methods inherited from class java.util.AbstractSet
equals, hashCode 
- 
Methods inherited from class java.util.AbstractCollection
toString 
- 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
- 
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray 
- 
Methods inherited from interface java.util.Set
spliterator 
 - 
 
 - 
 
- 
- 
Field Detail
- 
map
protected final ConcurrentMap<E,Object> map
 
 - 
 
- 
Constructor Detail
- 
ConcurrentHashSet
public ConcurrentHashSet()
 
- 
ConcurrentHashSet
public ConcurrentHashSet(int concurrencyLevel)
- Parameters:
 concurrencyLevel- passed in to the underlying CHM. SeeConcurrentHashMap(int, float, int)javadocs for details.
 
- 
ConcurrentHashSet
public ConcurrentHashSet(int initSize, float loadFactor, int concurrencyLevel)Params passed in to the underlying CHM. SeeConcurrentHashMap(int, float, int)javadocs for details. 
 - 
 
- 
Method Detail
- 
size
public int size()
- Specified by:
 sizein interfaceCollection<E>- Specified by:
 sizein interfaceSet<E>- Specified by:
 sizein classAbstractCollection<E>
 
- 
isEmpty
public boolean isEmpty()
- Specified by:
 isEmptyin interfaceCollection<E>- Specified by:
 isEmptyin interfaceSet<E>- Overrides:
 isEmptyin classAbstractCollection<E>
 
- 
contains
public boolean contains(Object o)
- Specified by:
 containsin interfaceCollection<E>- Specified by:
 containsin interfaceSet<E>- Overrides:
 containsin classAbstractCollection<E>
 
- 
toArray
public Object[] toArray()
- Specified by:
 toArrayin interfaceCollection<E>- Specified by:
 toArrayin interfaceSet<E>- Overrides:
 toArrayin classAbstractCollection<E>
 
- 
toArray
public <T> T[] toArray(T[] a)
- Specified by:
 toArrayin interfaceCollection<E>- Specified by:
 toArrayin interfaceSet<E>- Overrides:
 toArrayin classAbstractCollection<E>
 
- 
add
public boolean add(E o)
- Specified by:
 addin interfaceCollection<E>- Specified by:
 addin interfaceSet<E>- Overrides:
 addin classAbstractCollection<E>
 
- 
remove
public boolean remove(Object o)
- Specified by:
 removein interfaceCollection<E>- Specified by:
 removein interfaceSet<E>- Overrides:
 removein classAbstractCollection<E>
 
- 
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
 containsAllin interfaceCollection<E>- Specified by:
 containsAllin interfaceSet<E>- Overrides:
 containsAllin classAbstractCollection<E>
 
- 
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
 addAllin interfaceCollection<E>- Specified by:
 addAllin interfaceSet<E>- Overrides:
 addAllin classAbstractCollection<E>
 
- 
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
 retainAllin interfaceCollection<E>- Specified by:
 retainAllin interfaceSet<E>- Overrides:
 retainAllin classAbstractCollection<E>
 
- 
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
 removeAllin interfaceCollection<E>- Specified by:
 removeAllin interfaceSet<E>- Overrides:
 removeAllin classAbstractSet<E>
 
- 
clear
public void clear()
- Specified by:
 clearin interfaceCollection<E>- Specified by:
 clearin interfaceSet<E>- Overrides:
 clearin classAbstractCollection<E>
 
 - 
 
 -