E
- Element being wrapped by the list.public final class WeakList<E>
extends java.lang.Object
This is a very simple list implementation which does not implement the
standard Java collection List
interface. Currently, it has
only methods to add an entry to the end of the list, to iterate over all
elements from first to last, to indicate whether the list is empty and to
remove the specific element.
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.ref.Reference<E>> |
list
The internal list being wrapped
|
Constructor and Description |
---|
WeakList()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o)
Add an entry to the end of the list.
|
boolean |
isEmpty()
Indicate whether the list is empty.
|
java.util.Iterator<E> |
iterator()
Return an iterator on the elements in the list, starting from the first
and proceeding in order to the last.
|
boolean |
remove(E o)
Remove an entry from the list.
|
private final java.util.List<java.lang.ref.Reference<E>> list
public boolean add(E o)
o
- Object to be added via weak reference.true
if the list was changed as a result of the
call (always will return true
).public boolean isEmpty()
true
if the list contains no elements, else
false
.public boolean remove(E o)
o
- Object to be removed.true
if the list was changed as a result of the call.public java.util.Iterator<E> iterator()