Class BidiMap<K,V>

java.lang.Object
com.github.hypfvieh.collections.BidiMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class BidiMap<K,V> extends Object implements Map<K,V>
A bidirectional map. If created from an existing map, the original map is not modified. Instead a new Map objects of the same type are created for a copy of the original map and an inverted map. Should this fail, the type defaults to LinkedHashMap. Combinations of key-value must be unique in order to create and maintain the corresponding inverse map. In addition, null is not accepted as a valid value, as it is not permitted as a map key. In these cases IllegalArgumentException is thrown. The map requires external synchronization.
  • Constructor Details

    • BidiMap

      public BidiMap()
    • BidiMap

      public BidiMap(Map<K,V> _map)
  • Method Details

    • get

      public V get(Object _key)
      Specified by:
      get in interface Map<K,V>
    • getKey

      public K getKey(V _val)
    • containsKey

      public boolean containsKey(Object _key)
      Specified by:
      containsKey in interface Map<K,V>
    • containsValue

      public boolean containsValue(Object _val)
      Specified by:
      containsValue in interface Map<K,V>
    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
    • entrySet

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

      public V remove(Object _key)
      Specified by:
      remove in interface Map<K,V>
    • removeValue

      public K removeValue(V _val)
      Removes the mapping for a value from this map if it is present.
      Parameters:
      _val - value whose mapping is to be removed from the map
      Returns:
      the previous key associated with value.
    • put

      public V put(K _key, V _val)
      Specified by:
      put in interface Map<K,V>
    • putAll

      public void putAll(Map<? extends K, ? extends V> _map)
      Specified by:
      putAll in interface Map<K,V>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
    • toString

      public final String toString()
      Overrides:
      toString in class Object