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 aroundNonBlockingHashMapmaking it implement theSetinterface. 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 booleanadd(E o)Addoto the set.voidclear()Empty the set.booleancontains(Object o)Eget(E o)Iterator<E>iterator()booleanremove(Object o)Removeofrom the set.intsize()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)
Addoto the set.- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classAbstractCollection<E>- Returns:
- true if
owas added to the set, false ifowas already in the set.
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin classAbstractCollection<E>- Returns:
- true if
ois in the set.
-
remove
public boolean remove(Object o)
Removeofrom the set.- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classAbstractCollection<E>- Returns:
- true if
owas removed to the set, false ifowas 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:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>- Returns:
- count of elements.
-
clear
public void clear()
Empty the set.- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classAbstractCollection<E>
-
-