|
TUM CCSM Commons | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.tum.cs.commons.collections.TwoDimHashMap<K1,K2,I>
public class TwoDimHashMap<K1,K2,I>
A 2-dimensional hash map. Allows storage of items identified by two different keys. This can be used to store the following data structure:
| Constructor Summary | |
|---|---|
TwoDimHashMap()
Create a new doubly hashed map. |
|
TwoDimHashMap(Map<K1,Map<K2,I>> outerMap)
Create a new doubly hashed using the provided map as outer map. |
|
| Method Summary | |
|---|---|
void |
clear()
Clear the whole map. |
boolean |
containsKey(K1 firstKey,
K2 secondKey)
Returns whether the given key combination is available in the map. |
Set<K1> |
getFirstKeys()
Get all first level keys. |
Set<K2> |
getSecondKeys(K1 firstKey)
Get all the second level keys for a first key. |
int |
getSecondSize(K1 key1)
Get the size of the (second) map stored for a first key. |
int |
getSize()
Get size of the map. |
I |
getValue(K1 firstKey,
K2 secondKey)
Get a value by specifying first and second level key. |
List<I> |
getValues()
Get all values stored in the map. |
Collection<I> |
getValuesByFirstKey(K1 firstKey)
Get all values referenced by a first level key. |
List<I> |
getValuesBySecondKey(K2 secondKey)
Get all values referenced by a second level key. |
boolean |
isEmpty()
Check if the map is empty. |
void |
putAll(TwoDimHashMap<K1,K2,I> otherMap)
Put all values of another TwoDimHashMap into this map. |
void |
putValue(K1 key1,
K2 key2,
I value)
Put a doubly hashed value. |
boolean |
remove(K1 key)
Remove all values specified by first key. |
I |
remove(K1 key1,
K2 key2)
Removes the value associated to the key combination of key1 and key2. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TwoDimHashMap()
public TwoDimHashMap(Map<K1,Map<K2,I>> outerMap)
| Method Detail |
|---|
public void putAll(TwoDimHashMap<K1,K2,I> otherMap)
public void putValue(K1 key1,
K2 key2,
I value)
key1 - first level keykey2 - second level keyvalue - the value
public I getValue(K1 firstKey,
K2 secondKey)
Examples:
get("Project A", "Flo") => "Documentation"get("Project B", "Dan") => "QA"
firstKey - first level keysecondKey - second level key
null if first or second level key
does not exist or if null was explicitly stored.
public boolean containsKey(K1 firstKey,
K2 secondKey)
Example:
containsKey("Project A", "Flo") => truecontainsKey("Project X", "Flo") => false
firstKey - first level keysecondKey - second level keypublic Collection<I> getValuesByFirstKey(K1 firstKey)
Examples:
getValuesByFirstKey("Project A") => ("Testing", "Documentation")
firstKey - the first level key
public Set<K1> getFirstKeys()
getFirstKeys() => ("Project A", "Project B")
public Set<K2> getSecondKeys(K1 firstKey)
getFirstKeys("Project A") => ("Dan", "Flo")
firstKey - the first level key.
public List<I> getValuesBySecondKey(K2 secondKey)
Examples:
getValuesBySecondKey("Flo") => ("Documentation", "Design")
secondKey - the second level key
public List<I> getValues()
public int getSize()
public boolean isEmpty()
public int getSecondSize(K1 key1)
public void clear()
public I remove(K1 key1,
K2 key2)
key1 - key2 -
public boolean remove(K1 key)
key - first level key
true if key was present, false
otherwise
|
TUM CCSM Commons | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||