Modified from java.util.WeakHashMap.WeakKey. @version $Revision: 2787 $ @author Jason Dillon
103104105106107108109110111112
* @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); }
121122123124125126127128
* @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); }
144145146147148149150151152153154
/** * 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);
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);
848586878889909192
93949596979899100101102103
104105106107108109110111112113
122123124125126127128129
145146147148149150151152153154155