Class BiMap<K,V>

java.lang.Object
com.pnfsoftware.jeb.util.collect.BiMap<K,V>
Type Parameters:
K - key type; must have correct equals/hashCode
V - value type; must have correct equals/hashCode

@Ser public class BiMap<K,V> extends Object
A bidirectional map of key-values. This class is serialializable. The null key and null value are forbidden. The key-value mapping is one-to-one: a key can only map to one value, and one value can only map to one key. (One consequence is that putting a key-value pair may either increment, keep the same, or even decrement the map size.

Thread-safety: none.

Note: this class does not implement the Map interface, but attempts to follow its guidelines and contracts the best it can. One notable exception is that this class does not override hashCode/equals.

  • Constructor Details

    • BiMap

      public BiMap()
      Create a new bi-map.
    • BiMap

      public BiMap(CollectionOrder keyOrder)
      Create a new bi-map.
      Parameters:
      keyOrder -
  • Method Details

    • clear

      public void clear()
    • isEmpty

      public boolean isEmpty()
    • size

      public int size()
    • put

      public V put(K key, V value)
    • putAll

      public void putAll(Map<? extends K,? extends V> m)
    • containsKey

      public boolean containsKey(K key)
    • containsValue

      public boolean containsValue(V value)
    • get

      public V get(K key)
    • getKeyForValue

      public K getKeyForValue(V value)
    • remove

      public V remove(K key)
    • removeValue

      public K removeValue(V value)
    • keySet

      public Set<K> keySet()
    • values

      public Set<V> values()
    • asMap

      public Map<K,V> asMap()
    • asReverseMap

      public Map<V,K> asReverseMap()
    • toString

      public String toString()
      Overrides:
      toString in class Object