Modified from java.util.WeakHashMap.WeakKey. @version $Revision: 2787 $ @author Jason Dillon
68697071727374
* @param o * element whose presence in this collection is to be tested. * @return <tt>true</tt> if this collection contains the specified element */ public boolean contains(Object o) { return refrencedCollection.contains(new WeakObject(o)); }
9293949596979899
} return a; } public boolean add(Object o) { WeakObject weakObject = new WeakObject(o); return refrencedCollection.add(weakObject); }
979899100101102103104
WeakObject weakObject = new WeakObject(o); return refrencedCollection.add(weakObject); } public boolean remove(Object o) { WeakObject weakObject = new WeakObject(o); return refrencedCollection.remove(weakObject); }
87888990919293949596
/** * Maintain the elements in the set. Removes objects from the set that * have been reclaimed due to GC. */ protected final void maintain() { WeakObject weak; while ((weak = (WeakObject)queue.poll()) != null) { set.remove(weak); } }
120121122123124125126127128129130131132
/** The next available object. */ Object next = null; public boolean hasNext() { while (iter.hasNext()) { WeakObject weak = (WeakObject)iter.next(); Object obj = null; if (weak != null && (obj = weak.get()) == null) { // object has been reclaimed by the GC continue; } next = obj;
126127128129130131132133134135136137138
public boolean hasNext() { if (next != UNKNOWN) { return true; } while (iter.hasNext()) { WeakObject weak = (WeakObject)iter.next(); Object obj = null; if (weak != null && (obj = weak.get()) == null) { // object has been reclaimed by the GC continue; } next = obj; return true;
86878889909192939495
125126127128129130131132133134135136137