Package org.h2.util

Class SoftValuesHashMap<K,​V>

  • Type Parameters:
    K - the key type
    V - the value type
    All Implemented Interfaces:
    java.util.Map<K,​V>

    public class SoftValuesHashMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    Map which stores items using SoftReference. Items can be garbage collected and removed. It is not a general purpose cache, as it doesn't implement some methods, and others not according to the map definition, to improve speed.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  SoftValuesHashMap.SoftValue<T>
      A soft reference that has a hard reference to the key.
      • 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>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      V get​(java.lang.Object key)  
      private void processQueue()  
      V put​(K key, V value)
      Store the object.
      V remove​(java.lang.Object key)
      Remove an object.
      • Methods inherited from class java.util.AbstractMap

        clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, 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

      • SoftValuesHashMap

        public SoftValuesHashMap()
    • Method Detail

      • processQueue

        private void processQueue()
      • 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)
        Store the object. The return value of this method is null or a SoftReference.
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class java.util.AbstractMap<K,​V>
        Parameters:
        key - the key
        value - the value
        Returns:
        null or the old object.
      • remove

        public V remove​(java.lang.Object key)
        Remove an object.
        Specified by:
        remove in interface java.util.Map<K,​V>
        Overrides:
        remove in class java.util.AbstractMap<K,​V>
        Parameters:
        key - the key
        Returns:
        null or the old object
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
        Overrides:
        clear 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>