I wanted to implement SoftHashMap based on Java SoftReference and HashMap. Java docs, about WeakHashMap, say that keys are weak references rather than values. I was wondering what hashcode() would be used for put and pull functions of the underlying HashMap. I am assuming WeakHashMap put works like this: hashMap.put(new WeakReference(key), value); If this is true, how would the entry be found for a key.
Wouldn't it be better if values were wrapped in a WeakReference rather than keys?