JBoss Common Classes 2.2.17.GA

org.jboss.util.collection
Class WeakValueHashMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.jboss.util.collection.ReferenceValueMap<K,V>
          extended by org.jboss.util.collection.ReferenceValueHashMap<K,V>
              extended by org.jboss.util.collection.WeakValueHashMap<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
Map<K,V>

public class WeakValueHashMap<K,V>
extends ReferenceValueHashMap<K,V>

This Map will remove entries when the value in the map has been cleaned from garbage collection

Author:
Bill Burke, Adrian Brock, Ales Justin

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
WeakValueHashMap()
          Constructs a new, empty WeakValueHashMap with the default initial capacity and the default load factor, which is 0.75.
WeakValueHashMap(int initialCapacity)
          Constructs a new, empty WeakValueHashMap with the given initial capacity and the default load factor, which is 0.75.
WeakValueHashMap(int initialCapacity, float loadFactor)
          Constructs a new, empty WeakValueHashMap with the given initial capacity and the given load factor.
WeakValueHashMap(Map<K,V> t)
          Constructs a new WeakValueHashMap with the same mappings as the specified Map.
 
Method Summary
protected  ValueRef<K,V> create(K key, V value, ReferenceQueue<V> q)
          Create new value ref instance.
 
Methods inherited from class org.jboss.util.collection.ReferenceValueHashMap
createMap, createMap, createMap, createMap, createMap
 
Methods inherited from class org.jboss.util.collection.ReferenceValueMap
clear, containsKey, entrySet, get, put, remove, size, toString
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WeakValueHashMap

public WeakValueHashMap(int initialCapacity,
                        float loadFactor)
Constructs a new, empty WeakValueHashMap with the given initial capacity and the given load factor.

Parameters:
initialCapacity - The initial capacity of the WeakValueHashMap
loadFactor - The load factor of the WeakValueHashMap
Throws:
IllegalArgumentException - If the initial capacity is less than zero, or if the load factor is nonpositive

WeakValueHashMap

public WeakValueHashMap(int initialCapacity)
Constructs a new, empty WeakValueHashMap with the given initial capacity and the default load factor, which is 0.75.

Parameters:
initialCapacity - The initial capacity of the WeakValueHashMap
Throws:
IllegalArgumentException - If the initial capacity is less than zero

WeakValueHashMap

public WeakValueHashMap()
Constructs a new, empty WeakValueHashMap with the default initial capacity and the default load factor, which is 0.75.


WeakValueHashMap

public WeakValueHashMap(Map<K,V> t)
Constructs a new WeakValueHashMap with the same mappings as the specified Map. The WeakValueHashMap is created with an initial capacity of twice the number of mappings in the specified map or 11 (whichever is greater), and a default load factor, which is 0.75.

Parameters:
t - the map whose mappings are to be placed in this map.
Since:
1.3
Method Detail

create

protected ValueRef<K,V> create(K key,
                               V value,
                               ReferenceQueue<V> q)
Description copied from class: ReferenceValueMap
Create new value ref instance.

Specified by:
create in class ReferenceValueMap<K,V>
Parameters:
key - the key
value - the value
q - the ref queue
Returns:
new value ref instance

JBoss Common Classes 2.2.17.GA

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.