Package com.illumon.util.datastructures
Class WeakIdentityHashSet<TYPE>
java.lang.Object
com.illumon.util.datastructures.WeakIdentityHashSet<TYPE>
- Direct Known Subclasses:
WeakIdentityHashSet.Synchronized
public class WeakIdentityHashSet<TYPE> extends Object
An open-addressed identity hash set that only maintains weak references to its members.
Only supports
add(TYPE) and clear(). See WeakIdentityHashSet.Synchronized variant for concurrent usage.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWeakIdentityHashSet.Synchronized<TYPE>Thread-safe implementation. -
Constructor Summary
Constructors Constructor Description WeakIdentityHashSet() -
Method Summary
Modifier and Type Method Description booleanadd(TYPE value)Add a value to the set if its not already present.booleanadd(TYPE value, WeakReference<? extends TYPE> valueReference)Add a value to the set if its not already present.voidclear()Clear the set.voidforEach(Consumer<? super TYPE> action)Invoke an action on each member of the set.
-
Constructor Details
-
WeakIdentityHashSet
public WeakIdentityHashSet()
-
-
Method Details
-
clear
public void clear()Clear the set. -
add
Add a value to the set if its not already present.- Parameters:
value- The value to add- Returns:
- True if the value was added to the set
-
add
Add a value to the set if its not already present.- Parameters:
value- The value to addvalueReference- A re-usable WeakReference to value if already available, else null- Returns:
- True if the value was added to the set
-
forEach
Invoke an action on each member of the set.- Parameters:
action- The action to invoke
-