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>
public class NonBlockingHashSet<E> extends AbstractSet<E> implements Serializable
A simple wrapper aroundNonBlockingHashMap
making it implement theSet
interface. All operations are Non-Blocking and multi-thread safe.- Since:
- 1.5
- Author:
- Cliff Click
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NonBlockingHashSet()
Make a new emptyNonBlockingHashSet
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E o)
Addo
to the set.void
clear()
Empty the set.boolean
contains(Object o)
E
get(E o)
Iterator<E>
iterator()
boolean
remove(Object o)
Removeo
from the set.int
size()
Current count of elements in the set.-
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
-
-
-
-
Constructor Detail
-
NonBlockingHashSet
public NonBlockingHashSet()
Make a new emptyNonBlockingHashSet
.
-
-
Method Detail
-
add
public boolean add(E o)
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
public boolean contains(Object o)
- 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.
-
remove
public boolean remove(Object o)
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>
-
-