Class SoftRefMap<K,V>
- java.lang.Object
-
- com.inductiveautomation.ignition.common.util.SoftRefMap<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
public class SoftRefMap<K,V> extends java.lang.Object implements java.util.Map<K,V>
A very simple cache map implementation using soft references around the keys. This class is very much NOT thread-safe, so if there is any multi- threaded use, you must wrap in Collections.synchronizedMap(). Also, containsValue(), entrySet(), and values() are not supported. This class also doesn't prune the keys for cleared references aggressivly - you can prune them yourself by calling pruneClearedReferences()
XXX Colby says: just happened upon this... might be worth looking into replacing this class with the Google Collections MapMaker, which supports soft keys, concurrency, auto pruning, and a value generation function.
-
-
Constructor Summary
Constructors Constructor Description SoftRefMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
V
get(java.lang.Object key)
boolean
isEmpty()
java.util.Set<K>
keySet()
void
pruneClearedReferences()
V
put(K key, V value)
void
putAll(java.util.Map<? extends K,? extends V> t)
V
remove(java.lang.Object key)
int
size()
java.util.Collection<V>
values()
-
-
-
Method Detail
-
containsKey
public boolean containsKey(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
values
public java.util.Collection<V> values()
-
pruneClearedReferences
public void pruneClearedReferences()
-
-