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

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.WeakHashMap<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.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:
java.util.Map<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>>>>

public class WeakHashQuadMap<PRIMARY_KEY,SECONDARY_KEY,TERTIARY_KEY,QUATERNARY_KEY,ITEM>
extends java.util.WeakHashMap<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.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.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
WeakHashQuadMap()
           
WeakHashQuadMap(int primaryCapacity, int secondaryCapacity, int tertiaryCapacity, int quaternaryCapacity)
           
 
Method Summary
 java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>>> get(java.lang.Object key)
           
 java.util.Map<TERTIARY_KEY,java.util.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.
 java.util.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.
 java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>>> remove(java.lang.Object key)
           
 java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>> remove(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey)
           
 java.util.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 java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>>> get(java.lang.Object key)
Specified by:
get in interface java.util.Map<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>>>>
Overrides:
get in class java.util.WeakHashMap<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>>>>

get

public java.util.Map<TERTIARY_KEY,java.util.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 java.util.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 java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>>> remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>>>>
Overrides:
remove in class java.util.WeakHashMap<PRIMARY_KEY,java.util.Map<SECONDARY_KEY,java.util.Map<TERTIARY_KEY,java.util.Map<QUATERNARY_KEY,ITEM>>>>

remove

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

remove

public java.util.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)