Class PhantomValueTreeMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.arakhne.afc.references.AbstractReferencedValueMap<K,V>
-
- org.arakhne.afc.references.AbstractPhantomValueMap<K,V>
-
- org.arakhne.afc.references.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 withphantom 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 aTreeMap
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 istrue
, all the released references will be immediately removed from the map even if they are not enqueued by the virtual machine (seeAbstractReferencedValueMap.expurge()
. If this flag isfalse
, only the enqueued references will be removed from the map (seeAbstractReferencedValueMap.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.arakhne.afc.references.AbstractReferencedValueMap
AbstractReferencedValueMap.PhantomReferencedValue<VKT,VVT>, AbstractReferencedValueMap.ReferencableValue<K,V>, AbstractReferencedValueMap.SoftReferencedValue<VKT,VVT>, AbstractReferencedValueMap.WeakReferencedValue<VKT,VVT>
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
-
Fields inherited from class org.arakhne.afc.references.AbstractReferencedValueMap
map, NULL_VALUE
-
-
Constructor Summary
Constructors Constructor Description PhantomValueTreeMap()
Constructs an empty TreeMap.PhantomValueTreeMap(Comparator<? super K> comparator)
Constructs an empty TreeMap with the specified comparator.PhantomValueTreeMap(Map<? extends K,? extends V> map)
Constructs a new TreeMap with the same mappings as the specified Map.PhantomValueTreeMap(SortedMap<K,? extends V> map)
Constructs a new TreeMap with the same mappings and comparator as the specified Map.
-
Method Summary
-
Methods inherited from class org.arakhne.afc.references.AbstractPhantomValueMap
makeValue
-
Methods inherited from class org.arakhne.afc.references.AbstractReferencedValueMap
entrySet, equals, expurge, expurgeNow, expurgeQueuedReferences, finishToArray, hashCode, isDeeplyExpurge, makeValue, maskNull, put, setDeeplyExpurge, unmaskNull
-
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, get, isEmpty, keySet, putAll, remove, size, toString, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
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
-
-