Package javassist.scopedpool
Class SoftValueHashMap
- java.lang.Object
-
- java.util.AbstractMap
-
- javassist.scopedpool.SoftValueHashMap
-
- All Implemented Interfaces:
java.util.Map
public class SoftValueHashMap extends java.util.AbstractMap implements java.util.MapThis Map will remove entries when the value in the map has been cleaned from garbage collection- Version:
- $Revision: 1.4 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSoftValueHashMap.SoftValueRef
-
Constructor Summary
Constructors Constructor Description SoftValueHashMap()Constructs a new, emptyWeakHashMapwith the default initial capacity and the default load factor, which is0.75.SoftValueHashMap(int initialCapacity)Constructs a new, emptyWeakHashMapwith the given initial capacity and the default load factor, which is0.75.SoftValueHashMap(int initialCapacity, float loadFactor)Constructs a new, emptyWeakHashMapwith the given initial capacity and the given load factor.SoftValueHashMap(java.util.Map t)Constructs a newWeakHashMapwith the same mappings as the specified Map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all mappings from this map.booleancontainsKey(java.lang.Object key)Returnstrueif this map contains a mapping for the specified key.java.util.SetentrySet()Returns a set of the mappings contained in this hash table.java.lang.Objectget(java.lang.Object key)Returns the value to which this map maps the specifiedkey.booleanisEmpty()Returnstrueif this map contains no key-value mappings.private voidprocessQueue()java.lang.Objectput(java.lang.Object key, java.lang.Object value)Updates this map so that the givenkeymaps to the givenvalue.java.lang.Objectremove(java.lang.Object key)Removes the mapping for the givenkeyfrom this map, if present.intsize()Returns the number of key-value mappings in this map.-
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, keySet, putAll, toString, values
-
-
-
-
Constructor Detail
-
SoftValueHashMap
public SoftValueHashMap(int initialCapacity, float loadFactor)Constructs a new, emptyWeakHashMapwith the given initial capacity and the given load factor.- Parameters:
initialCapacity- The initial capacity of theWeakHashMaploadFactor- The load factor of theWeakHashMap- Throws:
java.lang.IllegalArgumentException- If the initial capacity is less than zero, or if the load factor is nonpositive
-
SoftValueHashMap
public SoftValueHashMap(int initialCapacity)
Constructs a new, emptyWeakHashMapwith the given initial capacity and the default load factor, which is0.75.- Parameters:
initialCapacity- The initial capacity of theWeakHashMap- Throws:
java.lang.IllegalArgumentException- If the initial capacity is less than zero
-
SoftValueHashMap
public SoftValueHashMap()
Constructs a new, emptyWeakHashMapwith the default initial capacity and the default load factor, which is0.75.
-
SoftValueHashMap
public SoftValueHashMap(java.util.Map t)
Constructs a newWeakHashMapwith the same mappings as the specified Map. TheWeakHashMapis 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.
-
-
Method Detail
-
entrySet
public java.util.Set entrySet()
Returns a set of the mappings contained in this hash table.- Specified by:
entrySetin interfacejava.util.Map- Specified by:
entrySetin classjava.util.AbstractMap
-
processQueue
private void processQueue()
-
size
public int size()
Returns the number of key-value mappings in this map. Note: In contrast with most implementations of theMapinterface, the time required by this operation is linear in the size of the map.- Specified by:
sizein interfacejava.util.Map- Overrides:
sizein classjava.util.AbstractMap
-
isEmpty
public boolean isEmpty()
Returnstrueif this map contains no key-value mappings.- Specified by:
isEmptyin interfacejava.util.Map- Overrides:
isEmptyin classjava.util.AbstractMap
-
containsKey
public boolean containsKey(java.lang.Object key)
Returnstrueif this map contains a mapping for the specified key.- Specified by:
containsKeyin interfacejava.util.Map- Overrides:
containsKeyin classjava.util.AbstractMap- Parameters:
key- The key whose presence in this map is to be tested.
-
get
public java.lang.Object get(java.lang.Object key)
Returns the value to which this map maps the specifiedkey. If this map does not contain a value for this key, then returnnull.- Specified by:
getin interfacejava.util.Map- Overrides:
getin classjava.util.AbstractMap- Parameters:
key- The key whose associated value, if any, is to be returned.
-
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value)Updates this map so that the givenkeymaps to the givenvalue. If the map previously contained a mapping forkeythen that mapping is replaced and the previous value is returned.- Specified by:
putin interfacejava.util.Map- Overrides:
putin classjava.util.AbstractMap- Parameters:
key- The key that is to be mapped to the givenvaluevalue- The value to which the givenkeyis to be mapped- Returns:
- The previous value to which this key was mapped, or
nullif if there was no mapping for the key
-
remove
public java.lang.Object remove(java.lang.Object key)
Removes the mapping for the givenkeyfrom this map, if present.- Specified by:
removein interfacejava.util.Map- Overrides:
removein classjava.util.AbstractMap- Parameters:
key- The key whose mapping is to be removed.- Returns:
- The value to which this key was mapped, or
nullif there was no mapping for the key.
-
clear
public void clear()
Removes all mappings from this map.- Specified by:
clearin interfacejava.util.Map- Overrides:
clearin classjava.util.AbstractMap
-
-