Package org.eclipse.sisu.inject
Class MildElements<T>
- java.lang.Object
-
- java.util.AbstractCollection<T>
-
- org.eclipse.sisu.inject.MildElements<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>
,java.util.Collection<T>
final class MildElements<T> extends java.util.AbstractCollection<T>
NON-thread-safeCollection
of elements kept alive by soft/weakReference
s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interface
MildElements.Indexable
Represents an element that can be indexed.(package private) class
MildElements.Itr
Iterator
that iterates over reachableReference
s in the list.private static class
MildElements.Soft<T>
SoftMildElements.Indexable
element.private static class
MildElements.Weak<T>
WeakMildElements.Indexable
element.
-
Constructor Summary
Constructors Constructor Description MildElements(java.util.List<java.lang.ref.Reference<T>> list, boolean soft)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T element)
private void
compact()
Compacts the list by replacing unreachableReference
s with ones from the end.(package private) void
evict(java.lang.ref.Reference<? extends T> ref)
Evicts a singleReference
from the list; replacing it with one from the end.java.util.Iterator<T>
iterator()
int
size()
-
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
MildElements
MildElements(java.util.List<java.lang.ref.Reference<T>> list, boolean soft)
-
-
Method Detail
-
add
public boolean add(T element)
-
size
public int size()
-
iterator
public java.util.Iterator<T> iterator()
-
compact
private void compact()
Compacts the list by replacing unreachableReference
s with ones from the end.
-
evict
void evict(java.lang.ref.Reference<? extends T> ref)
Evicts a singleReference
from the list; replacing it with one from the end.- Parameters:
ref
- The reference to evict
-
-