public class ConcurrentHashSet<E> extends AbstractSet<E> implements Serializable
ConcurrentHashMap
to 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.Modifier and Type | Field and Description |
---|---|
protected ConcurrentMap<E,Object> |
map |
Constructor and Description |
---|
ConcurrentHashSet() |
ConcurrentHashSet(int concurrencyLevel) |
ConcurrentHashSet(int initSize,
float loadFactor,
int concurrencyLevel)
Params passed in to the underlying CHM.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o) |
boolean |
addAll(Collection<? extends E> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
equals, hashCode
toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
spliterator
parallelStream, removeIf, stream
protected final ConcurrentMap<E,Object> map
public ConcurrentHashSet()
public ConcurrentHashSet(int concurrencyLevel)
concurrencyLevel
- passed in to the underlying CHM. See ConcurrentHashMap.ConcurrentHashMap(int,
float, int)
javadocs for details.public ConcurrentHashSet(int initSize, float loadFactor, int concurrencyLevel)
ConcurrentHashMap.ConcurrentHashMap(int,
float, int)
javadocs for details.public int size()
size
in interface Collection<E>
size
in interface Set<E>
size
in class AbstractCollection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in interface Set<E>
isEmpty
in class AbstractCollection<E>
public boolean contains(Object o)
contains
in interface Collection<E>
contains
in interface Set<E>
contains
in class AbstractCollection<E>
public Object[] toArray()
toArray
in interface Collection<E>
toArray
in interface Set<E>
toArray
in class AbstractCollection<E>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<E>
toArray
in interface Set<E>
toArray
in class AbstractCollection<E>
public boolean add(E o)
add
in interface Collection<E>
add
in interface Set<E>
add
in class AbstractCollection<E>
public boolean remove(Object o)
remove
in interface Collection<E>
remove
in interface Set<E>
remove
in class AbstractCollection<E>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
containsAll
in interface Set<E>
containsAll
in class AbstractCollection<E>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in interface Set<E>
addAll
in class AbstractCollection<E>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<E>
retainAll
in interface Set<E>
retainAll
in class AbstractCollection<E>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<E>
removeAll
in interface Set<E>
removeAll
in class AbstractSet<E>
public void clear()
clear
in interface Collection<E>
clear
in interface Set<E>
clear
in class AbstractCollection<E>
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.