org.mmbase.util
Class BijectiveMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.mmbase.util.BijectiveMap<K,V>
All Implemented Interfaces:
Serializable, Map<K,V>

public class BijectiveMap<K,V>
extends AbstractMap<K,V>
implements Serializable

A map representing a 1-1 bijective relation between 2 sets of values. So, this map can be turned around (getInverse()). resulting another BijectiveMap, but with keys an values switched.

Since:
MMBase-1.9.1
Version:
$Id: BijectiveMap.java 41418 2010-03-16 12:53:46Z michiel $
Author:
Michiel Meeuwissen
See Also:
Serialized Form

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
BijectiveMap()
           
 
Method Summary
 Set<Map.Entry<K,V>> entrySet()
           
 BijectiveMap<V,K> getInverse()
          Returns view on this map where the keys and values have switched their function.
 K inverseGet(V value)
          Gets a key by value.
 V put(K key, V value)
           
 
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

BijectiveMap

public BijectiveMap()
Method Detail

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in class AbstractMap<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMap<K,V>

inverseGet

public K inverseGet(V value)
Gets a key by value. That this is possible, is the essence of this class.


getInverse

public BijectiveMap<V,K> getInverse()
Returns view on this map where the keys and values have switched their function.



MMBase 2.0-SNAPSHOT - null