org.aspectbench.tm.runtime.internal
Class WeakKeyCollectingIdentityMap

java.lang.Object
  extended byorg.aspectbench.tm.runtime.internal.WeakKeyIdentityMap
      extended byorg.aspectbench.tm.runtime.internal.WeakKeyCollectingIdentityMap
All Implemented Interfaces:
java.util.Map

public class WeakKeyCollectingIdentityMap
extends WeakKeyIdentityMap

A Map implementation that uses reference identity of keys and holds weak references to its keys. When a key is garbage-collected, the corresponding key->value mapping is dropped. Note that this cleanup only happens upon certain map operations, so if they never occur the mapping will never be cleaned up. Periodically call isEmpty() (or somesuch) if you need to guarantee mappings expire. There's a potential race condition with the keySet method -- due to the above-mentioned cleanup, mappings may be removed even without explicit user intervention while the keyset is being iterated. Large parts of the Map interface aren't implemented as they are not necessary for the intended application (tracematch indexing) and would be rather less than straightforward to implement.

Author:
Pavel Avgustinov

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
WeakKeyCollectingIdentityMap()
           
 
Method Summary
 void clear()
           
 java.lang.Object get(java.lang.Object key)
           
 boolean isEmpty()
           
 java.util.Set keySet()
           
protected  void purge()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
protected  java.lang.Object writeBox(java.lang.Object key)
           
 
Methods inherited from class org.aspectbench.tm.runtime.internal.WeakKeyIdentityMap
containsKey, containsValue, entrySet, putAll, readBox, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

WeakKeyCollectingIdentityMap

public WeakKeyCollectingIdentityMap()
Method Detail

writeBox

protected java.lang.Object writeBox(java.lang.Object key)
Overrides:
writeBox in class WeakKeyIdentityMap

purge

protected void purge()

clear

public void clear()
Specified by:
clear in interface java.util.Map
Overrides:
clear in class WeakKeyIdentityMap

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map
Overrides:
get in class WeakKeyIdentityMap

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map
Overrides:
isEmpty in class WeakKeyIdentityMap

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map
Overrides:
keySet in class WeakKeyIdentityMap

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map
Overrides:
put in class WeakKeyIdentityMap

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map
Overrides:
remove in class WeakKeyIdentityMap

size

public int size()
Specified by:
size in interface java.util.Map
Overrides:
size in class WeakKeyIdentityMap