iitb.con.util
Class MultiKeyHashMap<K1,K2,V>

java.lang.Object
  extended by iitb.con.util.MultiKeyHashMap<K1,K2,V>

public class MultiKeyHashMap<K1,K2,V>
extends java.lang.Object

MultiKeyHashMap provides to store values with two level hierarchy of keys, super key (K1) and sub key (K2). The objects are inserted using super and sub keys. It is not mandatory to use both keys as hierarchy, user can use two keys to store the values and use either of the key to retrieve it.


Constructor Summary
MultiKeyHashMap()
          Initializes the MultiKeyHashMap
 
Method Summary
 void clear()
          Clears the entire hash map
 boolean containsKey(K1 k1)
          Returns true if value object is present for the specified (super)key K1
 boolean containsKey(K1 k1, K2 k2)
          Returns true if value object is present for the specified (super)key K1 and (sub)key K2
 java.util.Map<K2,V> get(K1 k1)
          Gets the value object for the specified (super)key K1
 V get(K1 k1, K2 k2)
          Gets the value object for the specified (super)key K1 and (sub)key K2
 java.util.List<V> getAllItems()
          Returns all the value objects in the MultiKeyHashMap
 V getBySubKey(K2 k2)
          Gets the value object for the specified (sub)key K2
 V put(K1 k1, K2 k2, V v)
          Puts the value object based on the (super)key K1 and (sub)key K2
 V remove(K1 k1, K2 k2)
          Removes the value object for the specified (super)key K1 and (sub)key K2
 int size()
          Size of MultiKeyHashMap
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiKeyHashMap

public MultiKeyHashMap()
Initializes the MultiKeyHashMap

Method Detail

clear

public void clear()
Clears the entire hash map


containsKey

public boolean containsKey(K1 k1)
Returns true if value object is present for the specified (super)key K1

Parameters:
k1 - key1 (super-key)
Returns:
true if value object present

containsKey

public boolean containsKey(K1 k1,
                           K2 k2)
Returns true if value object is present for the specified (super)key K1 and (sub)key K2

Parameters:
k1 - key1 (super-key)
k2 - key2 (sub-key)
Returns:
true if value object present

get

public java.util.Map<K2,V> get(K1 k1)
Gets the value object for the specified (super)key K1

Parameters:
k1 - key1 (super-key)
Returns:
HashMap structure contains the values for the key k1 if exists or null if does not exists

get

public V get(K1 k1,
             K2 k2)
Gets the value object for the specified (super)key K1 and (sub)key K2

Parameters:
k1 - key1 (super-key)
k2 - key2 (sub-key)
Returns:
value object if exists or null if does not exists

getAllItems

public java.util.List<V> getAllItems()
Returns all the value objects in the MultiKeyHashMap

Returns:
value objects as List

getBySubKey

public V getBySubKey(K2 k2)
Gets the value object for the specified (sub)key K2

Parameters:
k2 - key2 (sub-key)
Returns:
value object if exists or null if does not exists

put

public V put(K1 k1,
             K2 k2,
             V v)
Puts the value object based on the (super)key K1 and (sub)key K2

Parameters:
k1 - key1 (super-key)
k2 - key2 (sub-key)
v - value object
Returns:
previous value associated with specified key, or null if there was no mapping for key.

remove

public V remove(K1 k1,
                K2 k2)
Removes the value object for the specified (super)key K1 and (sub)key K2

Parameters:
k1 - key1 (super-key)
k2 - key2 (sub-key)
Returns:
previous value associated with specified key, or null if there was no mapping for key.

size

public int size()
Size of MultiKeyHashMap

Returns:
MultiKeyHashMap size