Class AbstractDualBidiMap

  • All Implemented Interfaces:
    java.util.Map, BidiMap, IterableMap
    Direct Known Subclasses:
    DualHashBidiMap, DualTreeBidiMap

    @Deprecated(since="2021-04-30")
    public abstract class AbstractDualBidiMap
    extends java.lang.Object
    implements BidiMap
    Deprecated.
    Commons Collections 3 is in maintenance mode. Commons Collections 4 should be used instead.
    Abstract BidiMap implemented using two maps.

    An implementation can be written simply by implementing the createMap method.

    Since:
    Commons Collections 3.0
    See Also:
    DualHashBidiMap, DualTreeBidiMap
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void clear()
      Deprecated.
       
      boolean containsKey​(java.lang.Object key)
      Deprecated.
       
      boolean containsValue​(java.lang.Object value)
      Deprecated.
       
      java.util.Set entrySet()
      Deprecated.
      Gets an entrySet view of the map.
      boolean equals​(java.lang.Object obj)
      Deprecated.
       
      java.lang.Object get​(java.lang.Object key)
      Deprecated.
       
      java.lang.Object getKey​(java.lang.Object value)
      Deprecated.
      Gets the key that is currently mapped to the specified value.
      int hashCode()
      Deprecated.
       
      BidiMap inverseBidiMap()
      Deprecated.
      Gets a view of this map where the keys and values are reversed.
      boolean isEmpty()
      Deprecated.
       
      java.util.Set keySet()
      Deprecated.
      Gets a keySet view of the map.
      MapIterator mapIterator()
      Deprecated.
      Obtains a MapIterator over the map.
      java.lang.Object put​(java.lang.Object key, java.lang.Object value)
      Deprecated.
      Puts the key-value pair into the map, replacing any previous pair.
      void putAll​(java.util.Map map)
      Deprecated.
       
      java.lang.Object remove​(java.lang.Object key)
      Deprecated.
       
      java.lang.Object removeValue​(java.lang.Object value)
      Deprecated.
      Removes the key-value pair that is currently mapped to the specified value (optional operation).
      int size()
      Deprecated.
       
      java.lang.String toString()
      Deprecated.
       
      java.util.Collection values()
      Deprecated.
      Gets a values view of the map.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Method Detail

      • get

        public java.lang.Object get​(java.lang.Object key)
        Deprecated.
        Specified by:
        get in interface java.util.Map
      • size

        public int size()
        Deprecated.
        Specified by:
        size in interface java.util.Map
      • isEmpty

        public boolean isEmpty()
        Deprecated.
        Specified by:
        isEmpty in interface java.util.Map
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Deprecated.
        Specified by:
        containsKey in interface java.util.Map
      • equals

        public boolean equals​(java.lang.Object obj)
        Deprecated.
        Specified by:
        equals in interface java.util.Map
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Deprecated.
        Specified by:
        hashCode in interface java.util.Map
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Deprecated.
        Overrides:
        toString in class java.lang.Object
      • put

        public java.lang.Object put​(java.lang.Object key,
                                    java.lang.Object value)
        Deprecated.
        Description copied from interface: BidiMap
        Puts the key-value pair into the map, replacing any previous pair.

        When adding a key-value pair, the value may already exist in the map against a different key. That mapping is removed, to ensure that the value only occurs once in the inverse map.

          BidiMap map1 = new DualHashBidiMap();
          map.put("A","B");  // contains A mapped to B, as per Map
          map.put("A","C");  // contains A mapped to C, as per Map
        
          BidiMap map2 = new DualHashBidiMap();
          map.put("A","B");  // contains A mapped to B, as per Map
          map.put("C","B");  // contains C mapped to B, key A is removed
         
        Specified by:
        put in interface BidiMap
        Specified by:
        put in interface java.util.Map
        Parameters:
        key - the key to store
        value - the value to store
        Returns:
        the previous value mapped to this key
      • putAll

        public void putAll​(java.util.Map map)
        Deprecated.
        Specified by:
        putAll in interface java.util.Map
      • remove

        public java.lang.Object remove​(java.lang.Object key)
        Deprecated.
        Specified by:
        remove in interface java.util.Map
      • clear

        public void clear()
        Deprecated.
        Specified by:
        clear in interface java.util.Map
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Deprecated.
        Specified by:
        containsValue in interface java.util.Map
      • mapIterator

        public MapIterator mapIterator()
        Deprecated.
        Obtains a MapIterator over the map. The iterator implements ResetableMapIterator. This implementation relies on the entrySet iterator.

        The setValue() methods only allow a new value to be set. If the value being set is already in the map, an IllegalArgumentException is thrown (as setValue cannot change the size of the map).

        Specified by:
        mapIterator in interface BidiMap
        Specified by:
        mapIterator in interface IterableMap
        Returns:
        a map iterator
      • getKey

        public java.lang.Object getKey​(java.lang.Object value)
        Deprecated.
        Description copied from interface: BidiMap
        Gets the key that is currently mapped to the specified value.

        If the value is not contained in the map, null is returned.

        Implementations should seek to make this method perform equally as well as get(Object).

        Specified by:
        getKey in interface BidiMap
        Parameters:
        value - the value to find the key for
        Returns:
        the mapped key, or null if not found
      • removeValue

        public java.lang.Object removeValue​(java.lang.Object value)
        Deprecated.
        Description copied from interface: BidiMap
        Removes the key-value pair that is currently mapped to the specified value (optional operation).

        If the value is not contained in the map, null is returned.

        Implementations should seek to make this method perform equally as well as remove(Object).

        Specified by:
        removeValue in interface BidiMap
        Parameters:
        value - the value to find the key-value pair for
        Returns:
        the key that was removed, null if nothing removed
      • inverseBidiMap

        public BidiMap inverseBidiMap()
        Deprecated.
        Description copied from interface: BidiMap
        Gets a view of this map where the keys and values are reversed.

        Changes to one map will be visible in the other and vice versa. This enables both directions of the map to be accessed as a Map.

        Implementations should seek to avoid creating a new object every time this method is called. See AbstractMap.values() etc. Calling this method on the inverse map should return the original.

        Specified by:
        inverseBidiMap in interface BidiMap
        Returns:
        an inverted bidirectional map
      • keySet

        public java.util.Set keySet()
        Deprecated.
        Gets a keySet view of the map. Changes made on the view are reflected in the map. The set supports remove and clear but not add.
        Specified by:
        keySet in interface java.util.Map
        Returns:
        the keySet view
      • values

        public java.util.Collection values()
        Deprecated.
        Gets a values view of the map. Changes made on the view are reflected in the map. The set supports remove and clear but not add.
        Specified by:
        values in interface java.util.Map
        Returns:
        the values view
      • entrySet

        public java.util.Set entrySet()
        Deprecated.
        Gets an entrySet view of the map. Changes made on the set are reflected in the map. The set supports remove and clear but not add.

        The Map Entry setValue() method only allow a new value to be set. If the value being set is already in the map, an IllegalArgumentException is thrown (as setValue cannot change the size of the map).

        Specified by:
        entrySet in interface java.util.Map
        Returns:
        the entrySet view