Package org.checkerframework.javacutil
Class CollectionUtils
java.lang.Object
org.checkerframework.javacutil.CollectionUtils
Utility methods related to Java Collections.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends @Nullable Object,
C extends @Nullable Collection<T>>
@PolyNull CcloneElements
(@PolyNull C orig) Returns a copy oforig
, where each element of the result is a clone of the corresponding element oforig
.cloneElements
(@PolyNull M orig) Returns a copy oforig
, where each key and value in the result is a clone of the corresponding element oforig
.cloneValues
(@PolyNull M orig) Returns a copy oforig
, where each value of the result is a clone of the corresponding value oforig
, but the keys are the same objects.static <K,
V> Map<K, V> createLRUCache
(int size) Creates a LRU cache.static <T extends @Nullable DeepCopyable<T>,
C extends @Nullable Collection<T>>
@PolyNull CReturns a copy oforig
, where each element of the result is a deep copy (according to theDeepCopyable
interface) of the corresponding element oforig
.static <K extends @Nullable DeepCopyable<K>,
V extends @Nullable DeepCopyable<V>, M extends @Nullable Map<K, V>>
@PolyNull MReturns a copy oforig
, where each key and value in the result is a deep copy (according to theDeepCopyable
interface) of the corresponding element oforig
.static <K,
V extends @Nullable DeepCopyable<V>, M extends @Nullable Map<K, V>>
@PolyNull MdeepCopyValues
(@PolyNull M orig) Returns a copy oforig
, where each value of the result is a deep copy (according to theDeepCopyable
interface) of the corresponding value oforig
, but the keys are the same objects.
-
Method Details
-
createLRUCache
Creates a LRU cache.- Parameters:
size
- size of the cache- Returns:
- a new cache with the provided size
-
cloneElements
public static <T extends @Nullable Object,C extends @Nullable Collection<T>> @PolyNull C cloneElements(@PolyNull C orig) Returns a copy oforig
, where each element of the result is a clone of the corresponding element oforig
.- Type Parameters:
T
- the type of elements of the collectionC
- the type of the collection- Parameters:
orig
- a collection- Returns:
- a copy of
orig
, as described above
-
cloneElements
Returns a copy oforig
, where each key and value in the result is a clone of the corresponding element oforig
.- Type Parameters:
K
- the type of keys of the mapV
- the type of values of the mapM
- the type of the map- Parameters:
orig
- a map- Returns:
- a copy of
orig
, as described above
-
cloneValues
Returns a copy oforig
, where each value of the result is a clone of the corresponding value oforig
, but the keys are the same objects.- Type Parameters:
K
- the type of keys of the mapV
- the type of values of the mapM
- the type of the map- Parameters:
orig
- a map- Returns:
- a copy of
orig
, as described above
-
deepCopy
public static <T extends @Nullable DeepCopyable<T>,C extends @Nullable Collection<T>> @PolyNull C deepCopy(@PolyNull C orig) Returns a copy oforig
, where each element of the result is a deep copy (according to theDeepCopyable
interface) of the corresponding element oforig
.- Type Parameters:
T
- the type of elements of the collectionC
- the type of the collection- Parameters:
orig
- a collection- Returns:
- a copy of
orig
, as described above
-
deepCopy
public static <K extends @Nullable DeepCopyable<K>,V extends @Nullable DeepCopyable<V>, @PolyNull M deepCopyM extends @Nullable Map<K, V>> (@PolyNull M orig) Returns a copy oforig
, where each key and value in the result is a deep copy (according to theDeepCopyable
interface) of the corresponding element oforig
.- Type Parameters:
K
- the type of keys of the mapV
- the type of values of the mapM
- the type of the map- Parameters:
orig
- a map- Returns:
- a copy of
orig
, as described above
-
deepCopyValues
public static <K,V extends @Nullable DeepCopyable<V>, @PolyNull M deepCopyValuesM extends @Nullable Map<K, V>> (@PolyNull M orig) Returns a copy oforig
, where each value of the result is a deep copy (according to theDeepCopyable
interface) of the corresponding value oforig
, but the keys are the same objects.- Type Parameters:
K
- the type of keys of the mapV
- the type of values of the mapM
- the type of the map- Parameters:
orig
- a map- Returns:
- a copy of
orig
, as described above
-