Package ghidra.pcodeCPort.utils
Class WeakHashMap2<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- ghidra.pcodeCPort.utils.WeakHashMap2<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
public class WeakHashMap2<K,V> extends java.util.AbstractMap<K,V>A hashtable-basedMapimplementation with weak values.This implementation uses two maps internally, which nearly doubles the memory requirements over a traditional map.
-
-
Constructor Summary
Constructors Constructor Description WeakHashMap2()Constructs a new, emptyWeakHashMap2with the default initial capacity and the default load factor, which is0.75.WeakHashMap2(int initialCapacity)Constructs a new, emptyWeakHashMap2with the given initial capacity and the default load factor, which is0.75.WeakHashMap2(int initialCapacity, float loadFactor)Constructs a new, emptyWeakHashMap2with the given initial capacity and the given load factor.WeakHashMap2(java.util.Map<K,V> t)Constructs a newWeakHashMap2with 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.Set<java.util.Map.Entry<K,V>>entrySet()Returns aSetview of the mappings in this map.Vget(java.lang.Object key)Returns the value to which this map maps the specifiedkey.booleanisEmpty()Returnstrueif this map contains no key-value mappings.Vput(K key, V value)Updates this map so that the givenkeymaps to the givenvalue.Vremove(java.lang.Object key)Removes the mapping for the givenkeyfrom this map, if present.KreverseGet(V value)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
-
WeakHashMap2
public WeakHashMap2(int initialCapacity, float loadFactor)Constructs a new, emptyWeakHashMap2with the given initial capacity and the given load factor.- Parameters:
initialCapacity- The initial capacity of theWeakHashMap2loadFactor- The load factor of theWeakHashMap2- Throws:
java.lang.IllegalArgumentException- If the initial capacity is less than zero, or if the load factor is nonpositive
-
WeakHashMap2
public WeakHashMap2(int initialCapacity)
Constructs a new, emptyWeakHashMap2with the given initial capacity and the default load factor, which is0.75.- Parameters:
initialCapacity- The initial capacity of theWeakHashMap2- Throws:
java.lang.IllegalArgumentException- If the initial capacity is less than zero
-
WeakHashMap2
public WeakHashMap2()
Constructs a new, emptyWeakHashMap2with the default initial capacity and the default load factor, which is0.75.
-
WeakHashMap2
public WeakHashMap2(java.util.Map<K,V> t)
Constructs a newWeakHashMap2with the same mappings as the specified Map. TheWeakHashMap2is 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
-
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.
-
isEmpty
public boolean isEmpty()
Returnstrueif this map contains no key-value mappings.
-
containsKey
public boolean containsKey(java.lang.Object key)
Returnstrueif this map contains a mapping for the specified key.
-
get
public V 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.
-
put
public V put(K key, V 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<K,V>- Overrides:
putin classjava.util.AbstractMap<K,V>- 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 V remove(java.lang.Object key)
Removes the mapping for the givenkeyfrom this map, if present.
-
clear
public void clear()
Removes all mappings from this map.
-
-