public class CachedList
extends java.util.AbstractList
List which translates added objects
into SoftObject references, allowing the VM to garbage collect
objects in the collection when memory is low.| Modifier and Type | Field and Description |
|---|---|
protected java.util.List |
list
Wrapped list.
|
protected java.lang.ref.ReferenceQueue |
queue
Reference queue.
|
| Constructor and Description |
|---|
CachedList()
Construct a CachedList using a LinkedList for
storage.
|
CachedList(java.util.List list)
Construct a CachedList.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
java.lang.Object obj)
Inserts the specified element at the specified position in this list
(optional operation).
|
java.lang.Object |
get(int index)
Returns the element at the specified position in this list.
|
private java.lang.Object |
getObject(int index)
Dereference the object at the given index.
|
private void |
maintain()
Maintains the collection by removing garbage collected objects.
|
java.lang.Object |
remove(int index)
Removes the element at the specified position in this list (optional
operation).
|
java.lang.Object |
set(int index,
java.lang.Object obj)
Replaces the element at the specified position in this list with the
specified element.
|
int |
size()
Return the size of the list.
|
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitprotected final java.lang.ref.ReferenceQueue queue
protected final java.util.List list
public CachedList(java.util.List list)
list - List to wrap.public CachedList()
private java.lang.Object getObject(int index)
public java.lang.Object get(int index)
get in interface java.util.Listget in class java.util.AbstractListindex - Index of element to return.public int size()
size in interface java.util.Collectionsize in interface java.util.Listsize in class java.util.AbstractCollectionpublic java.lang.Object set(int index,
java.lang.Object obj)
set in interface java.util.Listset in class java.util.AbstractListindex - Index of element to replace.obj - Element to be stored at the specified postion.public void add(int index,
java.lang.Object obj)
add in interface java.util.Listadd in class java.util.AbstractListindex - Index at which the specified element is to be inserted.obj - Element to be inserted.public java.lang.Object remove(int index)
remove in interface java.util.Listremove in class java.util.AbstractListindex - The index of the element to remove.private void maintain()