/[classpath]/classpath/java/util/WeakHashMap.java
ViewVC logotype

Diff of /classpath/java/util/WeakHashMap.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by ericb, Sat Feb 9 23:34:44 2002 UTC revision 1.13 by ericb, Sat Mar 9 04:01:12 2002 UTC
# Line 43  import java.lang.ref.WeakReference; Line 43  import java.lang.ref.WeakReference;
43  import java.lang.ref.ReferenceQueue;  import java.lang.ref.ReferenceQueue;
44    
45  /**  /**
46   * A weak hash map has only weak references to the key.  This means   * A weak hash map has only weak references to the key. This means that it
47   * that it allows the key to be garbage collected if they are not used   * allows the key to be garbage collected if it is not used otherwise. If
48   * otherwise.  If this happens, the weak hash map will eventually   * this happens, the entry will eventually disappear from the map,
49   * remove the whole entry from this map. <br>   * asynchronously.
50   *   *
51   * A weak hash map makes most sense, if the keys doesn't override the   * <p>A weak hash map makes most sense when the keys doesn't override the
52   * <code>equals</code>-method: If there is no other reference to the   * <code>equals</code> method: If there is no other reference to the
53   * key nobody can ever look up the key in this table and so the entry   * key nobody can ever look up the key in this table and so the entry
54   * can be removed.  This table also works, if the <code>equals</code>   * can be removed.  This table also works when the <code>equals</code>
55   * method is overloaded, e.g. with Strings as keys, but you should be   * method is overloaded, such as String keys, but you should be prepared
56   * prepared that some entries disappear spontaneously. <br>   * to deal with some entries disappearing spontaneously.
57   *   *
58   * You should also be prepared that this hash map behaves very   * <p>Other strange behaviors to be aware of: The size of this map may
59   * strange: The size of this map may spontaneously shrink (even if you   * spontaneously shrink (even if you use a synchronized map and synchronize
60   * use a synchronized map and synchronize it); it behaves as if   * it); it behaves as if another thread removes entries from this table
61   * another thread removes entries from this table without   * without synchronization.  The entry set returned by <code>entrySet</code>
  * synchronizations.  The entry set returned by <code>entrySet</code>  
62   * has similar phenomenons: The size may spontaneously shrink, or an   * has similar phenomenons: The size may spontaneously shrink, or an
63   * entry, that was in the set before, suddenly disappears. <br>   * entry, that was in the set before, suddenly disappears.
64   *   *
65   * A weak hash map is not meant for caches; use a normal map, with   * <p>A weak hash map is not meant for caches; use a normal map, with
66   * soft references as values instead, or try {@link LinkedHashMap}.  <br>   * soft references as values instead, or try {@link LinkedHashMap}.
67   *   *
68   * The weak hash map supports null values and null keys.  The null key   * <p>The weak hash map supports null values and null keys.  The null key
69   * is never deleted from the map (except explictly of course).   * is never deleted from the map (except explictly of course). The
70   * The performance of the methods are similar to that of a hash map. <br>   * performance of the methods are similar to that of a hash map.
71   *   *
72   * The value objects are strongly referenced by this table.  So if a   * <p>The value objects are strongly referenced by this table.  So if a
73   * value object maintains a strong reference to the key (either direct   * value object maintains a strong reference to the key (either direct
74   * or indirect) the key will never be removed from this map.  According   * or indirect) the key will never be removed from this map.  According
75   * to Sun, this problem may be fixed in a future release.  It is not   * to Sun, this problem may be fixed in a future release.  It is not

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26