Class WeakKeyValueMap<K,​V>

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

    public class WeakKeyValueMap<K,​V>
    extends java.lang.Object
    implements java.util.Map<K,​V>
    HashMap with weak reference on both sides.
    • 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>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.WeakHashMap<K,​java.lang.ref.WeakReference<V>> content
      The internal delegate map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears map.
      boolean containsKey​(java.lang.Object key)
      Returns if key is contained.
      boolean containsValue​(java.lang.Object value)
      Returns if value is contained.
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
      Returns the entry set.
      V get​(java.lang.Object key)
      Gets the value for key.
      boolean isEmpty()
      Returns if empty.
      java.util.Set<K> keySet()
      Returns the key set.
      V put​(K key, V value)
      Adds value for key.
      void putAll​(java.util.Map<? extends K,​? extends V> m)
      Adds other map content.
      V remove​(java.lang.Object key)
      Removes key.
      int size()
      Returns the size of the map.
      java.util.Collection<V> values()
      Returns the values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Field Detail

      • content

        protected java.util.WeakHashMap<K,​java.lang.ref.WeakReference<V>> content
        The internal delegate map.
    • Constructor Detail

      • WeakKeyValueMap

        public WeakKeyValueMap()
      • WeakKeyValueMap

        public WeakKeyValueMap​(java.util.Map<? extends K,​? extends V> m)
    • Method Detail

      • size

        public int size()
        Returns the size of the map.
        Specified by:
        size in interface java.util.Map<K,​V>
      • isEmpty

        public boolean isEmpty()
        Returns if empty.
        Specified by:
        isEmpty in interface java.util.Map<K,​V>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Returns if key is contained.
        Specified by:
        containsKey in interface java.util.Map<K,​V>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Returns if value is contained.
        Specified by:
        containsValue in interface java.util.Map<K,​V>
      • get

        public V get​(java.lang.Object key)
        Gets the value for key.
        Specified by:
        get in interface java.util.Map<K,​V>
      • put

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

        public V remove​(java.lang.Object key)
        Removes key.
        Specified by:
        remove in interface java.util.Map<K,​V>
      • putAll

        public void putAll​(java.util.Map<? extends K,​? extends V> m)
        Adds other map content.
        Specified by:
        putAll in interface java.util.Map<K,​V>
      • clear

        public void clear()
        Clears map.
        Specified by:
        clear in interface java.util.Map<K,​V>
      • keySet

        public java.util.Set<K> keySet()
        Returns the key set.
        Specified by:
        keySet in interface java.util.Map<K,​V>
      • values

        public java.util.Collection<V> values()
        Returns the values.
        Specified by:
        values in interface java.util.Map<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Returns the entry set.
        Specified by:
        entrySet in interface java.util.Map<K,​V>