edu.emory.mathcs.util.collections
Class WeakValueHashMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byedu.emory.mathcs.util.collections.WeakValueMap
          extended byedu.emory.mathcs.util.collections.WeakValueHashMap
All Implemented Interfaces:
java.util.Map
Direct Known Subclasses:
VolatileHashMap

public class WeakValueHashMap
extends edu.emory.mathcs.util.collections.WeakValueMap

Hash map that refers to values via weak references, thus not keeping them from garbage collection. After a value becomes unreferenced and collected, all the corresponding map entries are removed. (The cleanup is not asynchronous but piggybacks on other map operations). This class is a companion to WeakHashMap.

Version:
1.0
Author:
Dawid Kurzyniec

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
WeakValueHashMap()
          Creates new WeakValueHashMap with a default initial capacity and a default load factor.
WeakValueHashMap(int initialCapacity)
          Creates new WeakValueHashMap with specified initial capacity and a default load factor.
WeakValueHashMap(int initialCapacity, float loadFactor)
          Creates new WeakValueHashMap with specified initial capacity and load factor.
WeakValueHashMap(java.util.Map t)
          Creates new WeakValueHashMap with specified initial capacity and a default load factor, and copies to it all the mappings from the specified map.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set entrySet()
           
 java.lang.Object get(java.lang.Object key)
           
 boolean isEmpty()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map t)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, keySet, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode, keySet, values
 

Constructor Detail

WeakValueHashMap

public WeakValueHashMap(int initialCapacity,
                        float loadFactor)
Creates new WeakValueHashMap with specified initial capacity and load factor.

See Also:
java.util.HashMap(int,float)

WeakValueHashMap

public WeakValueHashMap(int initialCapacity)
Creates new WeakValueHashMap with specified initial capacity and a default load factor.

See Also:
java.util.HashMap(int)

WeakValueHashMap

public WeakValueHashMap()
Creates new WeakValueHashMap with a default initial capacity and a default load factor.

See Also:
java.util.HashMap(int)

WeakValueHashMap

public WeakValueHashMap(java.util.Map t)
Creates new WeakValueHashMap with specified initial capacity and a default load factor, and copies to it all the mappings from the specified map.

See Also:
java.util.HashMap(int)
Method Detail

size

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

clear

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

isEmpty

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

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map

putAll

public void putAll(java.util.Map t)
Specified by:
putAll in interface java.util.Map

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

get

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

remove

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

put

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