Class JdkBackedImmutableMap<K,​V>

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

    final class JdkBackedImmutableMap<K,​V>
    extends ImmutableMap<K,​V>
    Implementation of ImmutableMap backed by a JDK HashMap, which has smartness protecting against hash flooding.
    • Field Detail

      • delegateMap

        private final transient java.util.Map<K,​V> delegateMap
      • entries

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

      • JdkBackedImmutableMap

        JdkBackedImmutableMap​(java.util.Map<K,​V> delegateMap,
                              ImmutableList<java.util.Map.Entry<K,​V>> entries)
    • Method Detail

      • create

        static <K,​V> ImmutableMap<K,​V> create​(int n,
                                                          java.util.Map.Entry<K,​V>[] entryArray)
        Creates an ImmutableMap backed by a JDK HashMap. Used when probable hash flooding is detected. This implementation may replace the entries in entryArray with its own entry objects (though they will have the same key/value contents), and will take ownership of entryArray.
      • size

        public int size()
      • 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>
      • forEach

        public void forEach​(java.util.function.BiConsumer<? super K,​? super V> action)