Package net.engio.mbassy.common
Class AbstractConcurrentSet<T>
java.lang.Object
net.engio.mbassy.common.AbstractConcurrentSet<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
- Direct Known Subclasses:
StrongConcurrentSet,WeakConcurrentSet
This data structure is optimized for non-blocking reads even when write operations occur.
Running read iterators will not be affected by add operations since writes always insert at the head of the
structure. Remove operations can affect any running iterator such that a removed element that has not yet
been reached by the iterator will not appear in that iterator anymore.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AbstractConcurrentSet.Entry<T> private static final AtomicLongprivate final longprotected final ReentrantReadWriteLock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> elements) voidclear()booleanbooleancontainsAll(Collection<?> c) protected abstract AbstractConcurrentSet.Entry<T> createEntry(T value, AbstractConcurrentSet.Entry<T> next) booleaninthashCode()private booleanInserts a new element at the head of the set.booleanisEmpty()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
iterator, spliterator
-
Field Details
-
id
-
ID
private final long ID -
lock
-
entries
-
head
-
-
Constructor Details
-
AbstractConcurrentSet
-
-
Method Details
-
createEntry
protected abstract AbstractConcurrentSet.Entry<T> createEntry(T value, AbstractConcurrentSet.Entry<T> next) -
add
-
contains
-
insert
Inserts a new element at the head of the set. Note: This method is expected to be synchronized by the calling code -
size
public int size() -
isEmpty
public boolean isEmpty() -
addAll
-
remove
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceSet<T>
-
removeAll
-
retainAll
-
clear
public void clear() -
hashCode
public int hashCode() -
equals
-