Package org.jctools.maps
Class NonBlockingHashSet<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.jctools.maps.NonBlockingHashSet<E>
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,Set<E>
A simple wrapper around
NonBlockingHashMap
making it implement the
Set
interface. All operations are Non-Blocking and multi-thread safe.- Since:
- 1.5
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, retainAll, toArray, toArray, 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
addAll, containsAll, isEmpty, retainAll, spliterator, toArray, toArray
-
Field Details
-
V
-
_map
-
-
Constructor Details
-
NonBlockingHashSet
public NonBlockingHashSet()Make a new emptyNonBlockingHashSet
.
-
-
Method Details
-
add
Addo
to the set.- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classAbstractCollection<E>
- Returns:
- true if
o
was added to the set, false ifo
was already in the set.
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classAbstractCollection<E>
- Returns:
- true if
o
is in the set.
-
get
- Returns:
- Returns the match for
o
ifo
is in the set.
-
remove
Removeo
from the set.- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classAbstractCollection<E>
- Returns:
- true if
o
was removed to the set, false ifo
was not in the set.
-
size
public int size()Current count of elements in the set. Due to concurrent racing updates, the size is only ever approximate. Updates due to the calling thread are immediately visible to calling thread.- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
- Returns:
- count of elements.
-
clear
public void clear()Empty the set.- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in classAbstractCollection<E>
-
iterator
-