Class JdkBackedImmutableBiMap<K,​V>

  • All Implemented Interfaces:
    BiMap<K,​V>, java.io.Serializable, java.util.Map<K,​V>

    final class JdkBackedImmutableBiMap<K,​V>
    extends ImmutableBiMap<K,​V>
    Implementation of ImmutableBiMap backed by a pair of JDK HashMaps, which have smartness protecting against hash flooding.
    • Field Detail

      • entries

        private final transient ImmutableList<java.util.Map.Entry<K,​V>> entries
      • forwardDelegate

        private final java.util.Map<K,​V> forwardDelegate
      • backwardDelegate

        private final java.util.Map<V,​K> backwardDelegate
    • Constructor Detail

      • JdkBackedImmutableBiMap

        private JdkBackedImmutableBiMap​(ImmutableList<java.util.Map.Entry<K,​V>> entries,
                                        java.util.Map<K,​V> forwardDelegate,
                                        java.util.Map<V,​K> backwardDelegate)
    • Method Detail

      • create

        static <K,​V> ImmutableBiMap<K,​V> create​(int n,
                                                            java.util.Map.Entry<K,​V>[] entryArray)
      • size

        public int size()
      • inverse

        public ImmutableBiMap<V,​K> inverse()
        Description copied from class: ImmutableBiMap
        Returns the inverse view of this bimap, which maps each of this bimap's values to its associated key. The two bimaps are backed by the same data; any changes to one will appear in the other.

        Note:There is no guaranteed correspondence between the iteration order of a bimap and that of its inverse.

        The inverse of an ImmutableBiMap is another ImmutableBiMap.

        Specified by:
        inverse in interface BiMap<K,​V>
        Specified by:
        inverse in class ImmutableBiMap<K,​V>
        Returns:
        the inverse view of this bimap
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
        Specified by:
        get in class ImmutableMap<K,​V>