csli.util.collections.map
Class AbstractPairMap<K1,K2,V,M2 extends Map<K2,V>,M1 extends Map<K1,M2>>

java.lang.Object
  extended by java.util.AbstractMap<K1,M2>
      extended by csli.util.collections.map.AbstractPairMap<K1,K2,V,M2,M1>
Type Parameters:
K1 -
K2 -
V -
M2 -
M1 -
All Implemented Interfaces:
PairMap<K1,K2,V>, Map<K1,M2>
Direct Known Subclasses:
HPairMap, SmoothedPairDistribution

public abstract class AbstractPairMap<K1,K2,V,M2 extends Map<K2,V>,M1 extends Map<K1,M2>>
extends AbstractMap<K1,M2>
implements PairMap<K1,K2,V>

Implementation of PairMap routines that delegates responsibility to two (possibly the same) Map implementations. The PairMap is implemented as a Map1>. Classes derived from AbstractPairMap need to implement mapConstructor1 and mapConstructor2, which just provide a new instance of Map1 and Map2.

Author:
jefe

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
AbstractPairMap()
           
 
Method Summary
 boolean containsKey(Object key1, Object key2)
           
 Set<Map.Entry<K1,M2>> entrySet()
           
 Set<K1> firstKeys()
           
 V get(Object key1, Object key2)
           
 Map<K2,V> getMap(K1 key1)
           
 Set<Pair<K1,K2>> keys()
           
protected abstract  M1 mapConstructor1()
           
protected abstract  M2 mapConstructor2()
           
 V put(K1 key1, K2 key2, V value)
           
 M2 put(K1 key, M2 value)
           
 void putMap(K1 key1, Map<K2,V> argMap)
           
 V remove(Object key1, Object key2)
           
 Set<K2> secondKeys()
           
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractPairMap

public AbstractPairMap()
Method Detail

mapConstructor1

protected abstract M1 mapConstructor1()

mapConstructor2

protected abstract M2 mapConstructor2()

put

public V put(K1 key1,
             K2 key2,
             V value)
Specified by:
put in interface PairMap<K1,K2,V>

get

public V get(Object key1,
             Object key2)
Specified by:
get in interface PairMap<K1,K2,V>

containsKey

public boolean containsKey(Object key1,
                           Object key2)
Specified by:
containsKey in interface PairMap<K1,K2,V>

remove

public V remove(Object key1,
                Object key2)
Specified by:
remove in interface PairMap<K1,K2,V>

putMap

public void putMap(K1 key1,
                   Map<K2,V> argMap)
Specified by:
putMap in interface PairMap<K1,K2,V>

getMap

public Map<K2,V> getMap(K1 key1)
Specified by:
getMap in interface PairMap<K1,K2,V>

firstKeys

public Set<K1> firstKeys()
Specified by:
firstKeys in interface PairMap<K1,K2,V>

secondKeys

public Set<K2> secondKeys()
Specified by:
secondKeys in interface PairMap<K1,K2,V>

put

public M2 put(K1 key,
              M2 value)
Specified by:
put in interface Map<K1,M2 extends Map<K2,V>>
Overrides:
put in class AbstractMap<K1,M2 extends Map<K2,V>>

entrySet

public Set<Map.Entry<K1,M2>> entrySet()
Specified by:
entrySet in interface Map<K1,M2 extends Map<K2,V>>
Specified by:
entrySet in class AbstractMap<K1,M2 extends Map<K2,V>>

keys

public Set<Pair<K1,K2>> keys()
Specified by:
keys in interface PairMap<K1,K2,V>