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 AtomicLong
private final long
protected final ReentrantReadWriteLock
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends T> elements) void
clear()
boolean
boolean
containsAll
(Collection<?> c) protected abstract AbstractConcurrentSet.Entry
<T> createEntry
(T value, AbstractConcurrentSet.Entry<T> next) boolean
int
hashCode()
private boolean
Inserts a new element at the head of the set.boolean
isEmpty()
boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods 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:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceSet<T>
-
removeAll
-
retainAll
-
clear
public void clear() -
hashCode
public int hashCode() -
equals
-