cz.cuni.amis.utils.maps
Class WeakHashMapMap<PRIMARY_KEY,SECONDARY_KEY,ITEM>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.WeakHashMap<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,ITEM>>
cz.cuni.amis.utils.maps.WeakHashMapMap<PRIMARY_KEY,SECONDARY_KEY,ITEM>
- Type Parameters:
PRIMARY_KEY
- SECONDARY_KEY
- ITEM
-
- All Implemented Interfaces:
- java.util.Map<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,ITEM>>
public class WeakHashMapMap<PRIMARY_KEY,SECONDARY_KEY,ITEM>
- extends java.util.WeakHashMap<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,ITEM>>
Two-level hashMap where the first-level keys are weakly referenced!
This means that if the key is not strongly referenced elsewhere, the maps can be garbage collected.
Nested classes/interfaces inherited from class java.util.AbstractMap |
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Methods inherited from class java.util.WeakHashMap |
clear, containsKey, containsValue, entrySet, isEmpty, keySet, put, putAll, size, values |
Methods inherited from class java.util.AbstractMap |
clone, equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
WeakHashMapMap
public WeakHashMapMap()
get
public java.util.Map<SECONDARY_KEY,ITEM> get(java.lang.Object primaryKey)
- Specified by:
get
in interface java.util.Map<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,ITEM>>
- Overrides:
get
in class java.util.WeakHashMap<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,ITEM>>
get
public ITEM get(PRIMARY_KEY primaryKey,
SECONDARY_KEY secondaryKey)
- Returns the requested item under primary and secondary key.
- Parameters:
primaryKey
- weakly-referencedsecondaryKey
-
- Returns:
- if no such item exists returns NULL
put
public ITEM put(PRIMARY_KEY primaryKey,
SECONDARY_KEY secondaryKey,
ITEM item)
- Inserts item under primary and secondary_key.
- Parameters:
primaryKey
- weakly-referencedsecondaryKey
- item
-
- Returns:
- inserted item
remove
public ITEM remove(PRIMARY_KEY primaryKey,
SECONDARY_KEY secondaryKey)
- removes the item under primary and secondary key.
- Parameters:
primaryKey
- secondaryKey
-
- Returns:
- removed item
remove
public java.util.Map<SECONDARY_KEY,ITEM> remove(java.lang.Object primaryKey)
- removes all items under primaryKey
- Specified by:
remove
in interface java.util.Map<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,ITEM>>
- Overrides:
remove
in class java.util.WeakHashMap<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,ITEM>>
- Parameters:
primaryKey
-
- Returns:
- map of all removed items