Package org.arakhne.afc.references
Class AbstractReferencedSet<E,R extends Reference<E>>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- org.arakhne.afc.references.AbstractReferencedSet<E,R>
-
- Type Parameters:
E- is the type of the values.R- is the type of the references.
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
- Direct Known Subclasses:
SoftHashSet,SoftTreeSet,WeakHashSet,WeakTreeSet
public abstract class AbstractReferencedSet<E,R extends Reference<E>> extends AbstractSet<E>
A Set implementation withsoft valuesorweak values. An entry in a AbstractReferencedSet will automatically be removed when its value is no longer in ordinary use ornull.This abstract implementation does not decide if the map is based on a tree or on a hashtable.
- Since:
- 5.9
- Version:
- 17.0 2020-01-04 14:41:38
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- references
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractReferencedSet.ReferenceComparator<E,R extends Reference<E>>Comparator wrapper.
-
Constructor Summary
Constructors Constructor Description AbstractReferencedSet(Set<R> theSet, Class<? super R> referenceType)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanadd(E value)protected abstract RcreateReference(E element)Create a reference on the given object.booleanequals(Object obj)voidexpurge()Clean the references that was released.protected voidexpurgeNow()Clean the references that was marked as released inside the queue.voidexpurgeQueuedReferences()Clean the references that was marked as released inside the queue.inthashCode()booleanisDeeplyExpurge()Replies if this map expurge all the released references even if they are not enqueued by the virtual machine.Iterator<E>iterator()booleansetDeeplyExpurge(boolean deeplyExpurge)Set if this map expurge all the released references even if they are not enqueued by the virtual machine.intsize()-
Methods inherited from class java.util.AbstractSet
removeAll
-
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, 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
-
-
-
-
Method Detail
-
createReference
protected abstract R createReference(E element)
Create a reference on the given object.- Parameters:
element- is the element to wrap into a reference- Returns:
- the reference of the given element.
-
expurgeNow
protected final void expurgeNow()
Clean the references that was marked as released inside the queue.
-
isDeeplyExpurge
@Pure public final boolean isDeeplyExpurge()
Replies if this map expurge all the released references even if they are not enqueued by the virtual machine.- Returns:
trueis the values are deeply expurged when they are released from the moemory, otherwisefalse
-
setDeeplyExpurge
public final boolean setDeeplyExpurge(boolean deeplyExpurge)
Set if this map expurge all the released references even if they are not enqueued by the virtual machine.- Parameters:
deeplyExpurge- must betrueto expurge all the released values, otherwisefalseto expurge only the enqueued values.- Returns:
- the old value of this flag
-
expurgeQueuedReferences
public final void expurgeQueuedReferences()
Clean the references that was marked as released inside the queue.
-
expurge
public final void expurge()
Clean the references that was released.
-
equals
@Pure public final boolean equals(Object obj)
- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceSet<E>- Overrides:
equalsin classAbstractSet<E>
-
hashCode
@Pure public final int hashCode()
- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceSet<E>- Overrides:
hashCodein classAbstractSet<E>
-
size
@Pure public int size()
- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>
-
add
public boolean add(E value)
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classAbstractCollection<E>
-
-