Package io.deephaven.util.datastructures
Class LinkedWeakReferenceManager<T>
java.lang.Object
io.deephaven.util.datastructures.LinkedWeakReferenceManager<T>
- All Implemented Interfaces:
WeakReferenceManager<T>
Intrusive doubly-linked list implementation of
WeakReferenceManager
. This implementation is internally
synchronized to ensure that it is always safe for concurrent use, but operations may block.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Additem
to this WeakReferenceManager.void
clear()
Clear the list of references.void
forEachValidReference
(@NotNull Consumer<T> consumer, boolean parallel) Invokeconsumer.accept(item)
for each item previously added to this WeakReferenceManager whose reference has not been cleared (i.e.Retrieve the first valid item for whichtest.test(item)
returnstrue
.boolean
isEmpty()
Check whether this WeakReferenceManager is empty.void
Removeitem
from this WeakReferenceManager, along with any cleared references.void
removeAll
(@NotNull Collection<T> items) Remove all items initems
from this WeakReferenceManager, along with any cleared references.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.deephaven.util.datastructures.WeakReferenceManager
forEachValidReference
-
Constructor Details
-
LinkedWeakReferenceManager
public LinkedWeakReferenceManager()Create a LinkedWeakReferenceManager.
-
-
Method Details
-
add
Description copied from interface:WeakReferenceManager
Additem
to this WeakReferenceManager.- Specified by:
add
in interfaceWeakReferenceManager<T>
- Parameters:
item
- The item to add
-
remove
Description copied from interface:WeakReferenceManager
Removeitem
from this WeakReferenceManager, along with any cleared references. Comparison is strictly by reference equality, soitem
must be the same object as one previouslyadded
.- Specified by:
remove
in interfaceWeakReferenceManager<T>
- Parameters:
item
- The item to remove
-
removeAll
Description copied from interface:WeakReferenceManager
Remove all items initems
from this WeakReferenceManager, along with any cleared references. Comparison is strictly by reference equality.- Specified by:
removeAll
in interfaceWeakReferenceManager<T>
- Parameters:
items
- The items to remove
-
forEachValidReference
Description copied from interface:WeakReferenceManager
Invokeconsumer.accept(item)
for each item previously added to this WeakReferenceManager whose reference has not been cleared (i.e. because it was garbage-collected). Removes cleared references as a side effect.- Specified by:
forEachValidReference
in interfaceWeakReferenceManager<T>
- Parameters:
consumer
- The consumer to call for each valid itemparallel
- Whether to attempt to invokeconsumer
in parallel if the implementation supports this
-
getFirst
Description copied from interface:WeakReferenceManager
Retrieve the first valid item for whichtest.test(item)
returnstrue
. Any cleared references encountered are removed as a side effect.- Specified by:
getFirst
in interfaceWeakReferenceManager<T>
- Parameters:
test
- The test to decide if a valid item should be returned- Returns:
- The first valid item that passed
test
, ornull
if no such item existed
-
isEmpty
public boolean isEmpty()Description copied from interface:WeakReferenceManager
Check whether this WeakReferenceManager is empty. Does not check for cleared references, and so atrue
return does not guarantee that items will be encountered by subsequent methods.- Specified by:
isEmpty
in interfaceWeakReferenceManager<T>
- Returns:
- Whether this WeakReferenceManager is empty
-
clear
public void clear()Clear the list of references.- Specified by:
clear
in interfaceWeakReferenceManager<T>
-