cz.cuni.amis.utils.maps
Class WeakHashQuadMap<PRIMARY_KEY,SECONDARY_KEY,TERTIARY_KEY,QUATERNARY_KEY,ITEM>

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

public class WeakHashQuadMap<PRIMARY_KEY,SECONDARY_KEY,TERTIARY_KEY,QUATERNARY_KEY,ITEM>
extends WeakHashMap<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>>>>

A 4-level hashMap, the PrimaryKeys are weakly referenced. Get methods of all levels assure that the corresponding maps are created.

Author:
srlok

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
WeakHashQuadMap()
           
WeakHashQuadMap(int primaryCapacity, int secondaryCapacity, int tertiaryCapacity, int quaternaryCapacity)
           
 
Method Summary
 Map<SECONDARY_KEY,Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>>> get(Object key)
           
 Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>> get(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey)
          If the requested secondLevel map does not exist an empty one is created, inserted according to the primaryKey and returned.
 Map<QUATERNARY_KEY,ITEM> get(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey, TERTIARY_KEY tertiaryKey)
          If the requested level 3 map does not exist an empty one is created, inserted and returned.
 ITEM get(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey, TERTIARY_KEY tertiaryKey, QUATERNARY_KEY quaternaryKey)
          Returns null if the mapping is not present.
 ITEM put(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey, TERTIARY_KEY tertiaryKey, QUATERNARY_KEY quaternaryKey, ITEM item)
          Returns the inserted item.
 Map<SECONDARY_KEY,Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>>> remove(Object key)
           
 Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>> remove(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey)
           
 Map<QUATERNARY_KEY,ITEM> remove(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey, TERTIARY_KEY tertiaryKey)
           
 ITEM remove(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey, TERTIARY_KEY tertiaryKey, QUATERNARY_KEY quaternaryKey)
           
 
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

WeakHashQuadMap

public WeakHashQuadMap()

WeakHashQuadMap

public WeakHashQuadMap(int primaryCapacity,
                       int secondaryCapacity,
                       int tertiaryCapacity,
                       int quaternaryCapacity)
Method Detail

get

public Map<SECONDARY_KEY,Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>>> get(Object key)
Specified by:
get in interface Map<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>>>>
Overrides:
get in class WeakHashMap<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>>>>

get

public Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>> get(PRIMARY_KEY primaryKey,
                                                      SECONDARY_KEY secondaryKey)
If the requested secondLevel map does not exist an empty one is created, inserted according to the primaryKey and returned.

Parameters:
primaryKey -
secondaryKey -
Returns:

get

public Map<QUATERNARY_KEY,ITEM> get(PRIMARY_KEY primaryKey,
                                    SECONDARY_KEY secondaryKey,
                                    TERTIARY_KEY tertiaryKey)
If the requested level 3 map does not exist an empty one is created, inserted and returned.

Parameters:
primaryKey -
secondaryKey -
tertiaryKey -
Returns:

get

public ITEM get(PRIMARY_KEY primaryKey,
                SECONDARY_KEY secondaryKey,
                TERTIARY_KEY tertiaryKey,
                QUATERNARY_KEY quaternaryKey)
Returns null if the mapping is not present.

Parameters:
primaryKey -
secondaryKey -
tertiaryKey -
quaternaryKey -
Returns:

put

public ITEM put(PRIMARY_KEY primaryKey,
                SECONDARY_KEY secondaryKey,
                TERTIARY_KEY tertiaryKey,
                QUATERNARY_KEY quaternaryKey,
                ITEM item)
Returns the inserted item.

Parameters:
primaryKey -
secondaryKey -
tertiaryKey -
quaternaryKey -
item -
Returns:

remove

public Map<SECONDARY_KEY,Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>>> remove(Object key)
Specified by:
remove in interface Map<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>>>>
Overrides:
remove in class WeakHashMap<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>>>>

remove

public Map<TERTIARY_KEY,Map<QUATERNARY_KEY,ITEM>> remove(PRIMARY_KEY primaryKey,
                                                         SECONDARY_KEY secondaryKey)

remove

public Map<QUATERNARY_KEY,ITEM> remove(PRIMARY_KEY primaryKey,
                                       SECONDARY_KEY secondaryKey,
                                       TERTIARY_KEY tertiaryKey)

remove

public ITEM remove(PRIMARY_KEY primaryKey,
                   SECONDARY_KEY secondaryKey,
                   TERTIARY_KEY tertiaryKey,
                   QUATERNARY_KEY quaternaryKey)


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