Added prune method to remove collected observers from list.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2373 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -178,6 +178,18 @@ public class WeakObserverList<T> extends AbstractList<T>
|
|||||||
_wrappedList.apply(_derefOp);
|
_wrappedList.apply(_derefOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all garbage-collected observers from the list.
|
||||||
|
*/
|
||||||
|
public void prune ()
|
||||||
|
{
|
||||||
|
for (int ii = _wrappedList.size() - 1; ii >= 0; ii--) {
|
||||||
|
if (_wrappedList.get(ii).get() == null) {
|
||||||
|
_wrappedList.remove(ii);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An operation that resolves a reference and applies a wrapped op.
|
* An operation that resolves a reference and applies a wrapped op.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user