final class MildElements<T>
extends java.util.AbstractCollection<T>
Collection
of elements kept alive by soft/weak Reference
s.Modifier and Type | Class and Description |
---|---|
private static interface |
MildElements.Indexable
Represents an element that can be indexed.
|
(package private) class |
MildElements.Itr
Iterator that iterates over reachable Reference s in the list. |
private static class |
MildElements.Soft<T>
Soft
MildElements.Indexable element. |
private static class |
MildElements.Weak<T>
Weak
MildElements.Indexable element. |
Modifier and Type | Field and Description |
---|---|
(package private) java.util.List<java.lang.ref.Reference<T>> |
list |
private java.lang.ref.ReferenceQueue<T> |
queue |
private boolean |
soft |
Constructor and Description |
---|
MildElements(java.util.List<java.lang.ref.Reference<T>> list,
boolean soft) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T element) |
private void |
compact()
Compacts the list by replacing unreachable
Reference s with ones from the end. |
(package private) void |
evict(java.lang.ref.Reference<? extends T> ref)
Evicts a single
Reference from the list; replacing it with one from the end. |
java.util.Iterator<T> |
iterator() |
int |
size() |
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
private final java.lang.ref.ReferenceQueue<T> queue
final java.util.List<java.lang.ref.Reference<T>> list
private final boolean soft
MildElements(java.util.List<java.lang.ref.Reference<T>> list, boolean soft)
public boolean add(T element)
public int size()
public java.util.Iterator<T> iterator()
private void compact()
Reference
s with ones from the end.void evict(java.lang.ref.Reference<? extends T> ref)
Reference
from the list; replacing it with one from the end.ref
- The reference to evict