Class WeakValueHashMap<K,​V>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  WeakValueHashMap.ValueRef<K,​V>  
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

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

      Constructors 
      Constructor Description
      WeakValueHashMap()
      Constructs a new, empty WeakValueHashMap with the default initial capacity and the default load factor, which is 0.75.
      WeakValueHashMap​(int initialCapacity)
      Constructs a new, empty WeakValueHashMap with the given initial capacity and the default load factor, which is 0.75.
      WeakValueHashMap​(int initialCapacity, float loadFactor)
      Constructs a new, empty WeakValueHashMap with the given initial capacity and the given load factor.
      WeakValueHashMap​(java.util.Map<K,​V> t)
      Constructs a new WeakValueHashMap with the same mappings as the specified Map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      boolean containsKey​(java.lang.Object key)  
      protected java.util.Map<K,​WeakValueHashMap.ValueRef<K,​V>> createMap()
      Create map.
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      V get​(java.lang.Object key)  
      V put​(K key, V value)  
      V remove​(java.lang.Object key)  
      int size()  
      java.lang.String toString()  
      • Methods inherited from class java.util.AbstractMap

        clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, values
      • Methods inherited from class java.lang.Object

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

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

      • WeakValueHashMap

        public WeakValueHashMap​(int initialCapacity,
                                float loadFactor)
        Constructs a new, empty WeakValueHashMap with the given initial capacity and the given load factor.
        Parameters:
        initialCapacity - The initial capacity of the WeakValueHashMap
        loadFactor - The load factor of the WeakValueHashMap
        Throws:
        java.lang.IllegalArgumentException - If the initial capacity is less than zero, or if the load factor is nonpositive
      • WeakValueHashMap

        public WeakValueHashMap​(int initialCapacity)
        Constructs a new, empty WeakValueHashMap with the given initial capacity and the default load factor, which is 0.75.
        Parameters:
        initialCapacity - The initial capacity of the WeakValueHashMap
        Throws:
        java.lang.IllegalArgumentException - If the initial capacity is less than zero
      • WeakValueHashMap

        public WeakValueHashMap()
        Constructs a new, empty WeakValueHashMap with the default initial capacity and the default load factor, which is 0.75.
      • WeakValueHashMap

        public WeakValueHashMap​(java.util.Map<K,​V> t)
        Constructs a new WeakValueHashMap with the same mappings as the specified Map. The WeakValueHashMap is created with an initial capacity of twice the number of mappings in the specified map or 11 (whichever is greater), and a default load factor, which is 0.75.
        Parameters:
        t - the map whose mappings are to be placed in this map.
        Since:
        1.3
    • Method Detail

      • size

        public int size()
        Specified by:
        size in interface java.util.Map<K,​V>
        Overrides:
        size in class java.util.AbstractMap<K,​V>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​V>
        Overrides:
        containsKey in class java.util.AbstractMap<K,​V>
      • get

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

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class java.util.AbstractMap<K,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
        Overrides:
        remove in class java.util.AbstractMap<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
        Overrides:
        clear in class java.util.AbstractMap<K,​V>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractMap<K,​V>