home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / util / WeakHashMap.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.1 KB  |  90 lines

  1. package java.util;
  2.  
  3. import java.lang.ref.ReferenceQueue;
  4.  
  5. public class WeakHashMap extends AbstractMap implements Map {
  6.    private Map hash;
  7.    private ReferenceQueue queue;
  8.    private Set entrySet;
  9.  
  10.    private void processQueue() {
  11.       WeakKey var1;
  12.       while((var1 = (WeakKey)this.queue.poll()) != null) {
  13.          this.hash.remove(var1);
  14.       }
  15.  
  16.    }
  17.  
  18.    public WeakHashMap(int var1, float var2) {
  19.       this.queue = new ReferenceQueue();
  20.       this.entrySet = null;
  21.       this.hash = new HashMap(var1, var2);
  22.    }
  23.  
  24.    public WeakHashMap(int var1) {
  25.       this.queue = new ReferenceQueue();
  26.       this.entrySet = null;
  27.       this.hash = new HashMap(var1);
  28.    }
  29.  
  30.    public WeakHashMap() {
  31.       this.queue = new ReferenceQueue();
  32.       this.entrySet = null;
  33.       this.hash = new HashMap();
  34.    }
  35.  
  36.    public WeakHashMap(Map var1) {
  37.       this(Math.max(2 * var1.size(), 11), 0.75F);
  38.       ((AbstractMap)this).putAll(var1);
  39.    }
  40.  
  41.    public int size() {
  42.       return this.entrySet().size();
  43.    }
  44.  
  45.    public boolean isEmpty() {
  46.       return this.entrySet().isEmpty();
  47.    }
  48.  
  49.    public boolean containsKey(Object var1) {
  50.       return this.hash.containsKey(java.util.WeakHashMap.WeakKey.access$000(var1));
  51.    }
  52.  
  53.    public Object get(Object var1) {
  54.       return this.hash.get(java.util.WeakHashMap.WeakKey.access$000(var1));
  55.    }
  56.  
  57.    public Object put(Object var1, Object var2) {
  58.       this.processQueue();
  59.       return this.hash.put(java.util.WeakHashMap.WeakKey.access$100(var1, this.queue), var2);
  60.    }
  61.  
  62.    public Object remove(Object var1) {
  63.       this.processQueue();
  64.       return this.hash.remove(java.util.WeakHashMap.WeakKey.access$000(var1));
  65.    }
  66.  
  67.    public void clear() {
  68.       this.processQueue();
  69.       this.hash.clear();
  70.    }
  71.  
  72.    public Set entrySet() {
  73.       if (this.entrySet == null) {
  74.          this.entrySet = new EntrySet(this, (1)null);
  75.       }
  76.  
  77.       return this.entrySet;
  78.    }
  79.  
  80.    // $FF: synthetic method
  81.    static Map access$200(WeakHashMap var0) {
  82.       return var0.hash;
  83.    }
  84.  
  85.    // $FF: synthetic method
  86.    static void access$300(WeakHashMap var0) {
  87.       var0.processQueue();
  88.    }
  89. }
  90.