Class PhantomValueTreeMap<K,​V>

  • Type Parameters:
    K - is the type of the keys.
    V - is the type of the values.
    All Implemented Interfaces:
    Map<K,​V>

    public class PhantomValueTreeMap<K,​V>
    extends AbstractPhantomValueMap<K,​V>
    A Map implementation with phantom values. An entry in a PhantomValueTreeMap will automatically be removed when its value is no longer in ordinary use or null.

    This class was inspirated from WeakHashMap and uses a TreeMap as its internal data structure.

    This class has a special flag which permits to control the way how the released references are expurged: AbstractReferencedValueMap.isDeeplyExpurge(), AbstractReferencedValueMap.setDeeplyExpurge(boolean). If this flag is true, all the released references will be immediately removed from the map even if they are not enqueued by the virtual machine (see AbstractReferencedValueMap.expurge(). If this flag is false, only the enqueued references will be removed from the map (see AbstractReferencedValueMap.expurgeQueuedReferences().

    If this map does not use a "deep expurge" of the released references, it could contains null values that corresponds to values that are released by the garbage collector. If a "deep expurge" is used, all the values released by the garbage collector will be removed from the map.

    "Deep expurge" consumes much more time that "No deep expurge". This is the reason why this feature is not activated by default.

    The "deep expurge" feature was added to fix the uncoherent behavior of the garbage collector which seems to not always enqueued the released values (sometimes the queue is empty even if a value was released).

    Since:
    5.8
    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

      • PhantomValueTreeMap

        public PhantomValueTreeMap​(Comparator<? super K> comparator)
        Constructs an empty TreeMap with the specified comparator.
        Parameters:
        comparator - the comparator that will be used to order this map. If null, the natural ordering of the keys will be used.
      • PhantomValueTreeMap

        public PhantomValueTreeMap()
        Constructs an empty TreeMap.
      • PhantomValueTreeMap

        public PhantomValueTreeMap​(Map<? extends K,​? extends V> map)
        Constructs a new TreeMap with the same mappings as the specified Map.
        Parameters:
        map - the map whose mappings are to be placed in this map
        Throws:
        NullPointerException - if the specified map is null
      • PhantomValueTreeMap

        public PhantomValueTreeMap​(SortedMap<K,​? extends V> map)
        Constructs a new TreeMap with the same mappings and comparator as the specified Map.
        Parameters:
        map - the map whose mappings are to be placed in this map
        Throws:
        NullPointerException - if the specified map is null