Class MildKeys<K,​V>

  • All Implemented Interfaces:
    java.util.Map<K,​V>
    Direct Known Subclasses:
    MildConcurrentKeys

    class MildKeys<K,​V>
    extends java.lang.Object
    implements java.util.Map<K,​V>
    NON-thread-safe Map whose keys are kept alive by soft/weak References.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) class  MildKeys.EntryItr
      Iterator that iterates over reachable entries in the map.
      (package private) class  MildKeys.KeyItr
      Iterator that iterates over reachable keys in the map.
      (package private) static class  MildKeys.Soft<T>
      Soft key that maintains a constant hash and uses referential equality.
      (package private) class  MildKeys.StrongEntry
      Map.Entry that delegates to the original entry, but maintains a strong reference to the key.
      (package private) static class  MildKeys.Weak<T>
      Weak key that maintains a constant hash and uses referential equality.
      • 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
      (package private) java.util.Map<java.lang.ref.Reference<K>,​V> map  
      (package private) java.lang.ref.ReferenceQueue<K> queue  
      private boolean soft  
    • Constructor Summary

      Constructors 
      Constructor Description
      MildKeys​(java.util.Map<java.lang.ref.Reference<K>,​V> map, boolean soft)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      (package private) void compact()
      Compacts the map by removing cleared keys.
      boolean containsKey​(java.lang.Object key)  
      boolean containsValue​(java.lang.Object value)  
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      V get​(java.lang.Object key)  
      boolean isEmpty()  
      java.util.Set<K> keySet()  
      (package private) java.lang.ref.Reference<K> mildKey​(K key)  
      V put​(K key, V value)  
      void putAll​(java.util.Map<? extends K,​? extends V> m)  
      V remove​(java.lang.Object key)  
      int size()  
      (package private) static <K> java.lang.ref.Reference<K> tempKey​(K key)  
      java.util.Collection<V> 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

      • queue

        final java.lang.ref.ReferenceQueue<K> queue
      • map

        final java.util.Map<java.lang.ref.Reference<K>,​V> map
      • soft

        private final boolean soft
    • Constructor Detail

      • MildKeys

        MildKeys​(java.util.Map<java.lang.ref.Reference<K>,​V> map,
                 boolean soft)
    • Method Detail

      • containsKey

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

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

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

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

        public final void putAll​(java.util.Map<? extends K,​? extends V> m)
        Specified by:
        putAll in interface java.util.Map<K,​V>
      • remove

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

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

        public final boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<K,​V>
      • size

        public final int size()
        Specified by:
        size in interface java.util.Map<K,​V>
      • keySet

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

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

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

        final java.lang.ref.Reference<K> mildKey​(K key)
        Returns:
        Soft or weak Reference for the given key.
      • tempKey

        static final <K> java.lang.ref.Reference<K> tempKey​(K key)
        Returns:
        Temporary Reference for the given key; used in queries.
      • compact

        final void compact()
        Compacts the map by removing cleared keys.