Package one.pkg.tinyutils.containers
Class WeakList<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
one.pkg.tinyutils.containers.UnsafeWeakList<T>
one.pkg.tinyutils.containers.WeakList<T>
- Type Parameters:
T- the type of elements held in this collection
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>
Implementation of the
Collection interface which:
- Stores elements using weak semantics (see
WeakReference) - Automatically reclaims storage for garbage collected elements
- Is thread safe
- Is NOT RandomAccess, because garbage collector can remove element at any time
- Does NOT support null elements
add(T) and iterator().-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(@NotNull Collection<? extends T> c) booleanaddIfAbsent(T element) voidclear()booleanbooleanisEmpty()iterator()booleanbooleanremoveAll(@NotNull Collection<?> c) Methods inherited from class one.pkg.tinyutils.containers.UnsafeWeakList
containsAll, get, listSize, processQueue, sizeMethods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
containsAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Constructor Details
-
WeakList
public WeakList() -
WeakList
public WeakList(int initialCapacity)
-
-
Method Details
-
add
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceList<T>- Overrides:
addin classUnsafeWeakList<T>
-
addAll
- Specified by:
addAllin interfaceCollection<T>- Specified by:
addAllin interfaceList<T>- Overrides:
addAllin classUnsafeWeakList<T>
-
addIfAbsent
- Overrides:
addIfAbsentin classUnsafeWeakList<T>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceList<T>- Overrides:
clearin classUnsafeWeakList<T>
-
contains
- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceList<T>- Overrides:
containsin classUnsafeWeakList<T>
-
remove
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceList<T>- Overrides:
removein classUnsafeWeakList<T>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>- Specified by:
removeAllin interfaceList<T>- Overrides:
removeAllin classUnsafeWeakList<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceList<T>- Overrides:
isEmptyin classUnsafeWeakList<T>
-
iterator
-
toStrongList
- Overrides:
toStrongListin classUnsafeWeakList<T>
-
copyAndClear
-