gnu.java.util
Class WeakIdentityHashMap.WeakBucket

java.lang.Object
java.lang.ref.Reference
java.lang.ref.WeakReference
gnu.java.util.WeakIdentityHashMap.WeakBucket
- Enclosing class:
- WeakIdentityHashMap
- private static class WeakIdentityHashMap.WeakBucket
- extends java.lang.ref.WeakReference
A bucket is a weak reference to the key, that contains a strong
reference to the value, a pointer to the next bucket and its slot
number.
It would be cleaner to have a WeakReference as field, instead of
extending it, but if a weak reference gets cleared, we only get
the weak reference (by queue.poll) and wouldn't know where to
look for this reference in the hashtable, to remove that entry.
| Fields inherited from class java.lang.ref.Reference |
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
value
java.lang.Object value
- The value of this entry. The key is stored in the weak
reference that we extend.
next
WeakIdentityHashMap.WeakBucket next
- The next bucket describing another entry that uses the same
slot.
slot
int slot
- The slot of this entry. This should be
Math.abs(key.hashCode() % buckets.length).
But since the key may be silently removed we have to remember
the slot number.
If this bucket was removed the slot is -1. This marker will
prevent the bucket from being removed twice.
WeakIdentityHashMap.WeakBucket
public WeakIdentityHashMap.WeakBucket(java.lang.Object key,
java.lang.ref.ReferenceQueue queue,
java.lang.Object value,
int slot)
- Creates a new bucket for the given key/value pair and the specified
slot.
getEntry
WeakIdentityHashMap.WeakBucket.WeakEntry getEntry()
- This returns the entry stored in this bucket, or null, if the
bucket got cleared in the mean time.