public class TwoDimHashMap<K1,K2,V> extends java.lang.Object
| Constructor and Description |
|---|
TwoDimHashMap()
Create a new doubly hashed map.
|
TwoDimHashMap(java.util.Map<K1,java.util.Map<K2,V>> map)
Create a new two dimensional map using the data in the given map.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear the whole map.
|
boolean |
containsKey(K1 firstKey,
K2 secondKey)
Returns whether the given key combination is available in the map.
|
java.util.Set<K1> |
getFirstKeys()
Get all first level keys.
|
java.util.Set<K2> |
getSecondKeys(K1 firstKey)
Get all the second level keys stored under the given first level key.
|
UnmodifiableMap<K2,V> |
getSecondMap(K1 key)
Returns the data stored under the given first-level key as an
unmodifiable map or
null if nothing is stored under that
key. |
int |
getSecondSize(K1 key1)
Get the size of the (second) map stored for a first key.
|
int |
getSize()
Get size of the map.
|
V |
getValue(K1 firstKey,
K2 secondKey)
Get a value by specifying first and second level key.
|
java.util.List<V> |
getValues()
Get all values stored in the map.
|
java.util.Collection<V> |
getValuesByFirstKey(K1 firstKey)
Get all values referenced by a first level key.
|
java.util.List<V> |
getValuesBySecondKey(K2 secondKey)
Get all values referenced by a second level key.
|
boolean |
isEmpty()
Check if the map is empty, i.e.
|
void |
putAll(TwoDimHashMap<K1,K2,V> otherMap)
Put all values of another
TwoDimHashMap into this map. |
void |
putValue(K1 key1,
K2 key2,
V value)
Puts the given value into this map under the given keys.
|
boolean |
remove(K1 key)
Remove all values stored under the given first level key.
|
V |
remove(K1 key1,
K2 key2)
Removes the value associated with the given key combination.
|
public TwoDimHashMap()
public TwoDimHashMap(java.util.Map<K1,java.util.Map<K2,V>> map)
public void putAll(TwoDimHashMap<K1,K2,V> otherMap)
TwoDimHashMap into this map.public void putValue(K1 key1, K2 key2, V value)
key1 - first level keykey2 - second level keyvalue - the valuepublic V getValue(K1 firstKey, K2 secondKey)
firstKey - first level keysecondKey - second level keynull if first or second level key does
not exist or if null was explicitly stored.public boolean containsKey(K1 firstKey, K2 secondKey)
firstKey - first level keysecondKey - second level keypublic java.util.Collection<V> getValuesByFirstKey(K1 firstKey)
firstKey - the first level keypublic java.util.Set<K1> getFirstKeys()
public java.util.Set<K2> getSecondKeys(K1 firstKey)
firstKey - the first level key.public java.util.List<V> getValuesBySecondKey(K2 secondKey)
secondKey - the second level keypublic java.util.List<V> getValues()
public int getSize()
public boolean isEmpty()
public int getSecondSize(K1 key1)
public void clear()
public V remove(K1 key1, K2 key2)
null if there was no mapping for those keys. A
null return can also indicate that the map
previously associated null with the specified keys.public boolean remove(K1 key)
key - first level keytrue if the given key was present in the map,
false otherwise.public UnmodifiableMap<K2,V> getSecondMap(K1 key)
null if nothing is stored under that
key.