public class NonBlockingHashSet<E>
extends java.util.AbstractSet<E>
implements java.io.Serializable
NonBlockingHashMap
making it implement the
Set
interface. All operations are Non-Blocking and multi-thread safe.Constructor and Description |
---|
NonBlockingHashSet()
Make a new empty
NonBlockingHashSet . |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o)
Add
o to the set. |
E |
addIfAbsent(E o)
Add
o to the set. |
void |
clear()
Empty the set.
|
boolean |
contains(java.lang.Object o) |
E |
get(E o) |
java.util.Iterator<E> |
iterator() |
void |
readOnly()
Atomically make the set immutable.
|
boolean |
remove(java.lang.Object o)
Remove
o from the set. |
int |
size()
Current count of elements in the set.
|
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
public NonBlockingHashSet()
NonBlockingHashSet
.public boolean add(E o)
o
to the set.public E addIfAbsent(E o)
o
to the set.o
if it was already in the set, or o
otherwise.public boolean contains(java.lang.Object o)
public boolean remove(java.lang.Object o)
o
from the set.public int size()
public void clear()
public java.util.Iterator<E> iterator()
public void readOnly()
readOnly()
call returns. This call can be called concurrently
(and indeed until the operation completes, all calls on the Set from any
thread either complete normally or end up calling readOnly()
internally).
This call is useful in debugging multi-threaded programs where the
Set is constructed in parallel, but construction completes after some
time; and after construction the Set is only read. Making the Set
read-only will cause updates arriving after construction is supposedly
complete to throw an IllegalStateException
.