Package org.supercsv.util
Class TwoDHashMap<K1,K2,V>
- java.lang.Object
-
- org.supercsv.util.TwoDHashMap<K1,K2,V>
-
- Type Parameters:
K1- the first key typeK2- the second key typeV- the value type
public class TwoDHashMap<K1,K2,V> extends java.lang.ObjectA 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.- Since:
- 2.0.0 (migrated from Spiffy 0.5)
- See Also:
HashMap
-
-
Constructor Summary
Constructors Constructor Description TwoDHashMap()Constructs a new TwoDHashMap.TwoDHashMap(java.util.HashMap<K1,java.util.HashMap<K2,V>> map)Constructs a new TwoDHashMap using the supplied map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(K1 firstKey, K2 secondKey)Existence check of a value (or null) mapped to the keys.Vget(K1 firstKey, K2 secondKey)Fetch a value from the Hashmap .java.util.Set<K1>keySet()Returns a set of the keys of the outermost map.java.lang.Objectset(K1 firstKey, K2 secondKey, V value)Insert a valueintsize()Returns the number of key-value mappings in this map for the first key.intsize(K1 firstKey)Returns the number of key-value mappings in this map for the second key.
-
-
-
Method Detail
-
containsKey
public boolean containsKey(K1 firstKey, K2 secondKey)
Existence check of a value (or null) mapped to the keys.- Parameters:
firstKey- first keysecondKey- second key- Returns:
- true when an element (or null) has been stored with the keys
-
get
public V get(K1 firstKey, K2 secondKey)
Fetch a value from the Hashmap .- Parameters:
firstKey- first keysecondKey- second key- Returns:
- the element or null.
-
set
public java.lang.Object set(K1 firstKey, K2 secondKey, V value)
Insert a value- Parameters:
firstKey- first keysecondKey- second keyvalue- the value to be inserted. null may be inserted as well.- Returns:
- null or the value the insert is replacing.
-
size
public int size()
Returns the number of key-value mappings in this map for the first key.- Returns:
- Returns the number of key-value mappings in this map for the first key.
-
size
public int size(K1 firstKey)
Returns the number of key-value mappings in this map for the second key.- Parameters:
firstKey- the first key- Returns:
- Returns the number of key-value mappings in this map for the second key.
-
keySet
public java.util.Set<K1> keySet()
Returns a set of the keys of the outermost map.- Returns:
- the key set for the outermost map
-
-