Class AbstractReferencedSet<E,​R extends Reference<E>>

  • 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 with soft values or weak values. An entry in a AbstractReferencedSet will automatically be removed when its value is no longer in ordinary use or null.

    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
    • Constructor Detail

      • AbstractReferencedSet

        public AbstractReferencedSet​(Set<R> theSet,
                                     Class<? super R> referenceType)
        Constructor.
        Parameters:
        theSet - is the internal data structure to use.
        referenceType - is the type of the references.
    • 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, otherwise false
      • 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 be true to expurge all the released values, otherwise false 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.