public class HashMap2D<K1 extends java.lang.Comparable,K2 extends java.lang.Comparable,V> extends java.lang.Object implements Map2D<K1,K2,V>
The two dimensional hash map is implemented as a hash map of hash maps. Each "row" key points to a "column" hash map.
Example of use:
Map2D map = new HashMap2D(); map.put( "a" , "b" , "my value" ); String s = map.get( "a" , "b" );
Note: HashMap2D does not implement the Map interface.
Modifier and Type | Field and Description |
---|---|
protected int |
capacity
Initial capacity for child hash maps.
|
protected java.util.Map<K1,java.util.Map<K2,V>> |
localMap
Local map.
|
Constructor and Description |
---|
HashMap2D()
Create two dimensional hash map.
|
HashMap2D(int initialCapacity)
Create two dimensional hash map with specified initial row capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all entries from this map and its child maps.
|
java.util.Set<K2> |
columnKeySet()
Get column key set.
|
java.util.Set<K2> |
columnKeySet(java.lang.Object rowKey)
Get column key set with specified row value.
|
boolean |
containsKey(CompoundKey key)
Determine if map contains a compound key.
|
boolean |
containsKeys(java.lang.Object rowKey,
java.lang.Object columnKey)
Determine if map contains a key pair.
|
V |
get(CompoundKey key)
Get value at specified CompoundKey position.
|
V |
get(java.lang.Object rowKey,
java.lang.Object columnKey)
Get value at specified (rowKey, columnKey) position.
|
java.util.Set<CompoundKey> |
keySet()
Get the compound key set.
|
V |
put(K1 rowKey,
K2 columnKey,
V value)
Add value for specified (rowKey, columnKey) .
|
V |
remove(java.lang.Object rowKey,
java.lang.Object columnKey)
Remove entry at (rowKey, columnKey).
|
java.util.Set<K1> |
rowKeySet()
Get row key set.
|
int |
size()
Return number of entries.
|
java.lang.String |
toString()
Return formatted string displaying all entries.
|
protected java.util.Map<K1 extends java.lang.Comparable,java.util.Map<K2 extends java.lang.Comparable,V>> localMap
protected int capacity
public HashMap2D()
public HashMap2D(int initialCapacity)
initialCapacity
- public void clear()
public int size()
public boolean containsKeys(java.lang.Object rowKey, java.lang.Object columnKey)
containsKeys
in interface Map2D<K1 extends java.lang.Comparable,K2 extends java.lang.Comparable,V>
rowKey
- Row key.columnKey
- Column key.public boolean containsKey(CompoundKey key)
containsKey
in interface Map2D<K1 extends java.lang.Comparable,K2 extends java.lang.Comparable,V>
key
- Compound key.public V get(java.lang.Object rowKey, java.lang.Object columnKey)
public V get(CompoundKey key)
public V remove(java.lang.Object rowKey, java.lang.Object columnKey)
public java.util.Set<CompoundKey> keySet()
public java.util.Set<K1> rowKeySet()
public java.util.Set<K2> columnKeySet()
columnKeySet
in interface Map2D<K1 extends java.lang.Comparable,K2 extends java.lang.Comparable,V>
public java.util.Set<K2> columnKeySet(java.lang.Object rowKey)
Map2D
columnKeySet
in interface Map2D<K1 extends java.lang.Comparable,K2 extends java.lang.Comparable,V>
rowKey
- Row key value.public java.lang.String toString()
toString
in class java.lang.Object