Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.util
Class WeakIdentityHashMap.WeakBucket  view WeakIdentityHashMap.WeakBucket download WeakIdentityHashMap.WeakBucket.java

java.lang.Object
  extended byjava.lang.ref.Reference
      extended byjava.lang.ref.WeakReference
          extended bygnu.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.


Nested Class Summary
(package private)  class WeakIdentityHashMap.WeakBucket.WeakEntry
          This class gives the Entry representation of the current bucket.
 
Field Summary
(package private)  WeakIdentityHashMap.WeakBucket next
          The next bucket describing another entry that uses the same slot.
(package private)  int slot
          The slot of this entry.
(package private)  java.lang.Object value
          The value of this entry.
 
Fields inherited from class java.lang.ref.Reference
 
Constructor Summary
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.
 
Method Summary
(package private)  WeakIdentityHashMap.WeakBucket.WeakEntry getEntry()
          This returns the entry stored in this bucket, or null, if the bucket got cleared in the mean time.
 
Methods inherited from class java.lang.ref.Reference
clear, enqueue, get, isEnqueued
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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.

Constructor Detail

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.

Method Detail

getEntry

WeakIdentityHashMap.WeakBucket.WeakEntry getEntry()
This returns the entry stored in this bucket, or null, if the bucket got cleared in the mean time.