cz.cuni.amis.utils.maps
Class WeakHashMapMap<PRIMARY_KEY,SECONDARY_KEY,ITEM>

Package class diagram package WeakHashMapMap
java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.WeakHashMap<PRIMARY_KEY,Map<SECONDARY_KEY,ITEM>>
          extended by cz.cuni.amis.utils.maps.WeakHashMapMap<PRIMARY_KEY,SECONDARY_KEY,ITEM>
Type Parameters:
PRIMARY_KEY -
SECONDARY_KEY -
ITEM -
All Implemented Interfaces:
Map<PRIMARY_KEY,Map<SECONDARY_KEY,ITEM>>

public class WeakHashMapMap<PRIMARY_KEY,SECONDARY_KEY,ITEM>
extends WeakHashMap<PRIMARY_KEY,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.

Author:
srlok

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
WeakHashMapMap()
           
 
Method Summary
 Map<SECONDARY_KEY,ITEM> get(Object primaryKey)
           
 ITEM get(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey)
          Returns the requested item under primary and secondary key.
 ITEM put(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey, ITEM item)
          Inserts item under primary and secondary_key.
 Map<SECONDARY_KEY,ITEM> remove(Object primaryKey)
          removes all items under primaryKey
 ITEM remove(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey)
          removes the item under primary and secondary key.
 
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
 

Constructor Detail

WeakHashMapMap

public WeakHashMapMap()
Method Detail

get

public Map<SECONDARY_KEY,ITEM> get(Object primaryKey)
Specified by:
get in interface Map<PRIMARY_KEY,Map<SECONDARY_KEY,ITEM>>
Overrides:
get in class WeakHashMap<PRIMARY_KEY,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-referenced
secondaryKey -
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-referenced
secondaryKey -
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 Map<SECONDARY_KEY,ITEM> remove(Object primaryKey)
removes all items under primaryKey

Specified by:
remove in interface Map<PRIMARY_KEY,Map<SECONDARY_KEY,ITEM>>
Overrides:
remove in class WeakHashMap<PRIMARY_KEY,Map<SECONDARY_KEY,ITEM>>
Parameters:
primaryKey -
Returns:
map of all removed items


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.