Class BiMap<T1,​T2>

  • All Implemented Interfaces:
    java.io.Serializable

    public class BiMap<T1,​T2>
    extends java.lang.Object
    implements java.io.Serializable
    BiMap is a bi-directional map. It is intended to hold items, T1 and T2, that have a 1-1 relationship and it is desired to look up item T2 from T1 and look up T1 from T2. If a new item is inserted that already exists in the map the add will fail
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      BiMap()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAll​(BiMap<T1,​T2> iBiMap)  
      void addT1​(T1 iT1, T2 iT2)
      addT1 puts the iT1 and iT2 into the internal bi-maps. throws IllegalArgumentException if T1 or T2 already exist in the map
      void clear()
      clear will remove all entries in the bimaps
      boolean containsT1​(T1 iT1)
      containsT1 return true is iT1 is in the bi-maps
      boolean containsT2​(T2 iT2)
      containsT2 return true is iT2 is in the bi-maps
      java.util.Set<java.util.Map.Entry<T1,​T2>> entrySet()
      entrySet returns a Set of Entry objects from the bi-maps.
      T2 getByT1​(T1 iT1)  
      T1 getByT2​(T2 iT2)  
      boolean isEmpty()  
      java.util.Map.Entry<T1,​T2> removeByT1​(T1 iT1)
      removeByT1 removes the entry in the bi-maps corresponding to iT1.
      java.util.Map.Entry<T1,​T2> removeByT2​(T2 iT2)
      removeByT2 removes the entry in the bi-maps corresponding to iT2.
      int size()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BiMap

        public BiMap()
    • Method Detail

      • addT1

        public void addT1​(T1 iT1,
                          T2 iT2)
                   throws java.lang.IllegalArgumentException
        addT1 puts the iT1 and iT2 into the internal bi-maps. throws IllegalArgumentException if T1 or T2 already exist in the map
        Throws:
        java.lang.IllegalArgumentException
      • getByT2

        public T1 getByT2​(T2 iT2)
      • getByT1

        public T2 getByT1​(T1 iT1)
      • removeByT1

        public java.util.Map.Entry<T1,​T2> removeByT1​(T1 iT1)
        removeByT1 removes the entry in the bi-maps corresponding to iT1. Returns the entry of the map
      • removeByT2

        public java.util.Map.Entry<T1,​T2> removeByT2​(T2 iT2)
        removeByT2 removes the entry in the bi-maps corresponding to iT2. Returns the entry of the map
      • size

        public int size()
      • isEmpty

        public boolean isEmpty()
      • containsT1

        public boolean containsT1​(T1 iT1)
        containsT1 return true is iT1 is in the bi-maps
      • containsT2

        public boolean containsT2​(T2 iT2)
        containsT2 return true is iT2 is in the bi-maps
      • clear

        public void clear()
        clear will remove all entries in the bimaps
      • entrySet

        public java.util.Set<java.util.Map.Entry<T1,​T2>> entrySet()
        entrySet returns a Set of Entry objects from the bi-maps. It is intended to be used when iterating over the bi-maps. It works very similarly (same syntax) as the HashMap.entrySet(). However, the returned Set is independent of the contents of the bi-map. Thus, if you modify the returned Set, you will NOT modify the underlying bi-maps
      • addAll

        public void addAll​(BiMap<T1,​T2> iBiMap)