Class SoftHashMap.SoftValue

  • Enclosing class:
    SoftHashMap

    private static class SoftHashMap.SoftValue
    extends java.lang.ref.SoftReference
    We define our own subclass of SoftReference which contains not only the value but also the key to make it easier to find the entry in the HashMap after it's been garbage collected.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object key  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SoftValue​(java.lang.Object k, java.lang.Object key, java.lang.ref.ReferenceQueue q)
      Did you know that an outer class can access private data members and methods of an inner class? I didn't know that! I thought it was only the inner class who could access the outer class's private information.
    • Method Summary

      • Methods inherited from class java.lang.ref.SoftReference

        get
      • Methods inherited from class java.lang.ref.Reference

        clear, clone, enqueue, isEnqueued, reachabilityFence
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • key

        private final java.lang.Object key
    • Constructor Detail

      • SoftValue

        private SoftValue​(java.lang.Object k,
                          java.lang.Object key,
                          java.lang.ref.ReferenceQueue q)
        Did you know that an outer class can access private data members and methods of an inner class? I didn't know that! I thought it was only the inner class who could access the outer class's private information. An outer class can also access private members of an inner class inside its inner class.