Class LazyLoadingCachingMap<K,V>
java.lang.Object
ghidra.program.database.data.LazyLoadingCachingMap<K,V>
- Type Parameters:
K- the key type.V- the value type.
Instances of this class will provide a simple map interface to a cached set of key,value
pairs. This class requires that the map can be generated from scratch at any time and
that adding/removing items from this map is just a mirroring of those changes elsewhere.
This map is lazy in that it won't load the data until needed and it will use a soft reference
to maintain the map until such time as the java garbage collector decides to reclaim it.
This class uses a ghidra Lock object to coordinate threaded access when loading the underlying map data. It manages both the lock and its own synchronization to avoid race conditions and deadlocks.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes any cached map of values and restores the map to its initial state.Retrieves the value for the given key.getMap()Note: this map is always called from either a synchronized block or code holding the "lock".loadMap()This method will reload the map data from scratch.voidAdds the key,value pair to the map.voidRemoves the key,value pair from the map as specified by the given key.values()Returns an unmodifiable view of the values in this map.
-
Constructor Details
-
LazyLoadingCachingMap
-
-
Method Details
-
loadMap
-
put
-
remove
Removes the key,value pair from the map as specified by the given key. If the map is currently not loaded, this method will do nothing.- Parameters:
key- the key to remove from the map.
-
clear
public void clear()Removes any cached map of values and restores the map to its initial state. -
get
-
values
Returns an unmodifiable view of the values in this map.- Returns:
- an unmodifiable view of the values in this map.
-
getMap
-