|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object spiffy.core.util.TwoDHashMap<K1,K2,V>
public class TwoDHashMap<K1,K2,V>
A two-dimensional hashmap, is a HashMap that enables you to refer to values via two keys rather than one. The underlying implementation is simply a HashMap containing HashMap, each of which maps to values.
This is quite useful e.g. when wanting to cache values such as "currency ration" based keys "day of year" and "year".
HashMap
Constructor Summary | |
---|---|
TwoDHashMap()
|
|
TwoDHashMap(HashMap<K1,HashMap<K2,V>> map)
|
Method Summary | |
---|---|
boolean |
containsKey(K1 firstKey,
K2 secondKey)
Existence check of a value (or null) mapped to the keys. |
V |
get(K1 firstKey,
K2 secondKey)
Fetch a value from the Hashmap . |
Set<K1> |
keySet()
Returns a set of the keys of the outermost map. |
Object |
set(K1 firstKey,
K2 secondKey,
V value)
Insert a value |
int |
size()
Returns the number of key-value mappings in this map for the first key. |
int |
size(K1 firstKey)
Returns the number of key-value mappings in this map for the second key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TwoDHashMap()
public TwoDHashMap(HashMap<K1,HashMap<K2,V>> map)
Method Detail |
---|
public boolean containsKey(K1 firstKey, K2 secondKey)
firstKey
- first keysecondKey
- second key
public V get(K1 firstKey, K2 secondKey)
firstKey
- first keysecondKey
- second key
public Object set(K1 firstKey, K2 secondKey, V value)
firstKey
- first keysecondKey
- second keyvalue
- the value to be inserted. null may be inserted as well.
public int size()
public int size(K1 firstKey)
public Set<K1> keySet()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |