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 values
orweak 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 class
AbstractReferencedSet.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 boolean
add(E value)
protected abstract R
createReference(E element)
Create a reference on the given object.boolean
equals(Object obj)
void
expurge()
Clean the references that was released.protected void
expurgeNow()
Clean the references that was marked as released inside the queue.void
expurgeQueuedReferences()
Clean the references that was marked as released inside the queue.int
hashCode()
boolean
isDeeplyExpurge()
Replies if this map expurge all the released references even if they are not enqueued by the virtual machine.Iterator<E>
iterator()
boolean
setDeeplyExpurge(boolean deeplyExpurge)
Set if this map expurge all the released references even if they are not enqueued by the virtual machine.int
size()
-
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:
true
is 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 betrue
to expurge all the released values, otherwisefalse
to 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:
equals
in interfaceCollection<E>
- Specified by:
equals
in interfaceSet<E>
- Overrides:
equals
in classAbstractSet<E>
-
hashCode
@Pure public final int hashCode()
- Specified by:
hashCode
in interfaceCollection<E>
- Specified by:
hashCode
in interfaceSet<E>
- Overrides:
hashCode
in classAbstractSet<E>
-
size
@Pure public int size()
- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
add
public boolean add(E value)
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classAbstractCollection<E>
-
-