Modified from java.util.WeakHashMap.WeakKey. @version $Revision: 2787 $ @author Jason Dillon
838485868788899091
* @return True if object was added. */ public boolean add(final Object obj) { maintain(); SoftObject soft = SoftObject.create(obj, queue); return collection.add(soft); }
9293949596979899100101102
/** * Maintains the collection by removing garbage collected objects. */ private void maintain() { SoftObject obj; int count = 0; while ((obj = (SoftObject)queue.poll()) != null) { count++; collection.remove(obj);
104105106107108109110111112113
* @return The previous element at the given index. */ public Object set(final int index, final Object obj) { maintain(); SoftObject soft = SoftObject.create(obj, queue); soft = (SoftObject)list.set(index, soft); return Objects.deref(soft); }
122123124125126127128129
* @param obj Element to be inserted. */ public void add(final int index, final Object obj) { maintain(); SoftObject soft = SoftObject.create(obj, queue); list.add(index, soft); }
145146147148149150151152153154155
/** * Maintains the collection by removing garbage collected objects. */ private void maintain() { SoftObject obj; int count = 0; while ((obj = (SoftObject)queue.poll()) != null) { count++; list.remove(obj);