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

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

public class HashTriMap<PRIMARY_KEY,SECONDARY_KEY,TERTIARY_KEY,ITEM>
extends HashMap<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,ITEM>>>

Three-level thread-safe hash map, implemented via synchronized maps (Collections.synchronizedMap)

Author:
srlok
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
HashTriMap()
           
HashTriMap(int primaryCapacity, int secondaryCapacity, int tertiaryCapacity)
           
 
Method Summary
 Map<SECONDARY_KEY,Map<TERTIARY_KEY,ITEM>> get(Object primaryKey)
          Returns a HashMap> Never returns null, if the map under primary key doesn't exist, an empty one is added and returned.
 Map<TERTIARY_KEY,ITEM> get(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey)
          Returns the requested map, never returns null.
 ITEM get(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey, TERTIARY_KEY tertiaryKey)
          Returns item specified, returns null if item does not appear in the map.
 void put(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey, TERTIARY_KEY tertiaryKey, ITEM item)
          Puts the item into the map.
 Map<SECONDARY_KEY,Map<TERTIARY_KEY,ITEM>> remove(Object primaryKey)
          Removes the requested map.
 Map<TERTIARY_KEY,ITEM> remove(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey)
          removes the map under primary and secondary key, if the map does not exist, the data structure is not changed and a new map is returned.
 ITEM remove(PRIMARY_KEY primaryKey, SECONDARY_KEY secondaryKey, TERTIARY_KEY tertiaryKey)
          Returns the item under specified keys and removes it from the map, returns null if item is not present in the map.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, put, putAll, size, values
 
Methods inherited from class java.util.AbstractMap
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

HashTriMap

public HashTriMap()

HashTriMap

public HashTriMap(int primaryCapacity,
                  int secondaryCapacity,
                  int tertiaryCapacity)
Method Detail

get

public Map<SECONDARY_KEY,Map<TERTIARY_KEY,ITEM>> get(Object primaryKey)
Returns a HashMap> Never returns null, if the map under primary key doesn't exist, an empty one is added and returned.

Specified by:
get in interface Map<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,ITEM>>>
Overrides:
get in class HashMap<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,ITEM>>>
Parameters:
primaryKey -
Returns:

get

public Map<TERTIARY_KEY,ITEM> get(PRIMARY_KEY primaryKey,
                                  SECONDARY_KEY secondaryKey)
Returns the requested map, never returns null. If the map does not exist an empty map is created and returned.

Parameters:
primaryKey -
secondaryKey -
Returns:

get

public ITEM get(PRIMARY_KEY primaryKey,
                SECONDARY_KEY secondaryKey,
                TERTIARY_KEY tertiaryKey)
Returns item specified, returns null if item does not appear in the map.

Parameters:
primaryKey -
secondaryKey -
tertiaryKey -
Returns:

put

public void put(PRIMARY_KEY primaryKey,
                SECONDARY_KEY secondaryKey,
                TERTIARY_KEY tertiaryKey,
                ITEM item)
Puts the item into the map.

Parameters:
primaryKey -
secondaryKey -
tertiaryKey -
item -

remove

public Map<SECONDARY_KEY,Map<TERTIARY_KEY,ITEM>> remove(Object primaryKey)
Removes the requested map. If the map doesn't exist, returns an empty map.

Specified by:
remove in interface Map<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,ITEM>>>
Overrides:
remove in class HashMap<PRIMARY_KEY,Map<SECONDARY_KEY,Map<TERTIARY_KEY,ITEM>>>

remove

public Map<TERTIARY_KEY,ITEM> remove(PRIMARY_KEY primaryKey,
                                     SECONDARY_KEY secondaryKey)
removes the map under primary and secondary key, if the map does not exist, the data structure is not changed and a new map is returned.

Parameters:
primaryKey -
secondaryKey -
Returns:

remove

public ITEM remove(PRIMARY_KEY primaryKey,
                   SECONDARY_KEY secondaryKey,
                   TERTIARY_KEY tertiaryKey)
Returns the item under specified keys and removes it from the map, returns null if item is not present in the map.

Parameters:
primaryKey -
secondaryKey -
tertiaryKey -
Returns:


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