Class WeakCollection<E>
java.lang.Object
java.util.AbstractCollection<E>
io.github.thecsdev.tcdcommons.api.util.collections.WeakCollection<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
A
Collection
that stores its elements in form of WeakReference
s-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
final int
cleanUp()
Cleans up "expired"WeakReference
s whoseObject
s got garbage collected.final void
clear()
final boolean
final int
Returns the number ofWeakReference
s that no longer have a value assigned to them.iterator()
final ListIterator
<E> final int
size()
Methods inherited from class java.util.AbstractCollection
addAll, 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
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
list
-
-
Constructor Details
-
WeakCollection
public WeakCollection()
-
-
Method Details
-
cleanUp
public final int cleanUp()Cleans up "expired"WeakReference
s whoseObject
s got garbage collected.- Returns:
- The number of cleaned-up entries.
-
garbageSize
public final int garbageSize()Returns the number ofWeakReference
s that no longer have a value assigned to them. -
contains
- Specified by:
contains
in interfaceCollection<E>
- Overrides:
contains
in classAbstractCollection<E>
-
add
- Specified by:
add
in interfaceCollection<E>
- Overrides:
add
in classAbstractCollection<E>
-
size
public final int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in classAbstractCollection<E>
-
clear
public final void clear()- Specified by:
clear
in interfaceCollection<E>
- Overrides:
clear
in classAbstractCollection<E>
-
iterator
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in classAbstractCollection<E>
-
listIterator
-