|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.util.SimpleWeakList
public class SimpleWeakList
List of objects which are held onto weakly. This class is meant to be subclassed in order to do truly interesting things with the contents of the list.
| Constructor Summary | |
|---|---|
SimpleWeakList()
Construct an instance with an initial capacity of 4. |
|
SimpleWeakList(int initialCapacity)
Construct an instance. |
|
| Method Summary | |
|---|---|
protected void |
accept(Object obj)
Method called by accept(Object,Object) in response to a call
to forEachAccept() or forEachAccept(Object). |
protected void |
accept(Object obj,
Object arg)
Method called by forEachAccept(Object). |
void |
add(Object obj)
Add an object to the end of the list maintained this instance. |
boolean |
contains(Object obj)
Determine if the list already contains an object. |
void |
forEachAccept()
Call accept(java.lang.Object) on each live object in the list, in order. |
void |
forEachAccept(Object arg)
Call accept(java.lang.Object) on each live object in the list, in order. |
Object |
get(int n)
Get the nth object in the list, which may turn out to
be a reaped reference. |
protected boolean |
matchesTarget(Object toCompare,
Object target)
Method called by remove(java.lang.Object) and contains(java.lang.Object). |
void |
remove(Object obj)
Remove an object from this instance that had previously been added. |
int |
size()
Get the size of the list (which may include reaped references). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleWeakList(int initialCapacity)
initialCapacity - initial capacity of the list; it will
expand as neededpublic SimpleWeakList()
4.
| Method Detail |
|---|
public final void add(Object obj)
obj - non-null; the object to addpublic final void remove(Object obj)
obj - non-null; an object identifying the object to be
removed. If the result of passing an object from the list and
this object to matchesTarget(java.lang.Object, java.lang.Object) is true, then the object
from the list is removed.
IllegalArgumentException - thrown if the
obj had not been added to this instancepublic final boolean contains(Object obj)
obj - an object identifying the object to look for.
If the result of passing an object from the list and
this object to matchesTarget(java.lang.Object, java.lang.Object) is true, then this method
returns true.public final int size()
public final Object get(int n)
nth object in the list, which may turn out to
be a reaped reference.
n - which element to get
nth object, or null
if it was reapedpublic final void forEachAccept()
accept(java.lang.Object) on each live object in the list, in order.
public final void forEachAccept(Object arg)
accept(java.lang.Object) on each live object in the list, in order.
arg - used as second argument to accept(java.lang.Object).protected void accept(Object obj)
accept(Object,Object) in response to a call
to forEachAccept() or forEachAccept(Object).
This implementation does
nothing, but subclasses may override it to do something interesting,
if need be.
You should override either this method, or
accept(Object,Object), but not both.
obj - non-null; a live object from the list
protected void accept(Object obj,
Object arg)
forEachAccept(Object).
This implementation does
nothing, but subclasses may override it to do something interesting,
if need be.
You should override either this method, or
accept(Object), but not both.
obj - non-null; a live object from the listarg - argument passed into forEachAccept(Object).
protected boolean matchesTarget(Object toCompare,
Object target)
remove(java.lang.Object) and contains(java.lang.Object).
This implementation simply compares the two arguments using ==.
toCompare - non-null; an object in the listtarget - non-null; the argument originally passed into
remove(java.lang.Object) or contains(java.lang.Object).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||