JUtil

net.cscott.jutil
Class GenericInvertibleMap<K,V>

java.lang.Object
  extended by net.cscott.jutil.MapWrapper<K,V>
      extended by net.cscott.jutil.GenericInvertibleMap<K,V>
All Implemented Interfaces:
Map<K,V>, InvertibleMap<K,V>

public class GenericInvertibleMap<K,V>
extends MapWrapper<K,V>
implements InvertibleMap<K,V>

GenericInvertibleMap is a default implementation of InvertibleMap. It returns unmodifiable inverted views of the mappings it maintains.

Version:
$Id: GenericInvertibleMap.java,v 1.5 2006-10-30 19:58:05 cananian Exp $
Author:
Felix S. Klock II

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
GenericInvertibleMap()
          Constructs an invertible map backed by a HashMap.
GenericInvertibleMap(Map<K,V> m)
           
GenericInvertibleMap(MapFactory<K,V> mf, MultiMapFactory<V,K> mmf)
          Constructs an invertible map backed by a map constructed by mf and an inverted map constructed by mmf.
 
Method Summary
 MultiMap<V,K> invert()
          Returns an unmodifiable inverted view of this.
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> m)
           
 V remove(Object key)
           
protected  Map<K,V> wrapped()
           
 
Methods inherited from class net.cscott.jutil.MapWrapper
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, size, toString, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, size, values
 

Constructor Detail

GenericInvertibleMap

public GenericInvertibleMap()
Constructs an invertible map backed by a HashMap.


GenericInvertibleMap

public GenericInvertibleMap(MapFactory<K,V> mf,
                            MultiMapFactory<V,K> mmf)
Constructs an invertible map backed by a map constructed by mf and an inverted map constructed by mmf.


GenericInvertibleMap

public GenericInvertibleMap(Map<K,V> m)
Method Detail

wrapped

protected Map<K,V> wrapped()
Specified by:
wrapped in class MapWrapper<K,V>

invert

public MultiMap<V,K> invert()
Returns an unmodifiable inverted view of this.

Specified by:
invert in interface InvertibleMap<K,V>

put

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

putAll

public void putAll(Map<? extends K,? extends V> m)
Specified by:
putAll in interface Map<K,V>
Overrides:
putAll in class MapWrapper<K,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class MapWrapper<K,V>

JUtil

Copyright (c) 2006 C. Scott Ananian