Package pascal.taie.util.collection
Class CollectionUtils
java.lang.Object
pascal.taie.util.collection.CollectionUtils
Utility methods for
Collection
.
We name it CollectionUtils instead of Collections to avoid name collision
with Collections
.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>
append
(Collection<? extends T> c, T e) Creates a list of given collection, appends a specific element to the list and returns it.static <T> T
findFirst
(Collection<? extends T> c, Predicate<? super T> p) Iterates the elements in the specific collection, in the order they are returned by the collection's iterator, and finds the first element of given collection that satisfies the predicate.static <T> T
getOne
(Collection<T> c) static <T> long
sum
(Collection<? extends T> c, ToIntFunction<T> toInt) Maps each element in given collection to an integer and computes the sum of the integers.static <T> Set<T>
toSet
(Collection<T> c) Converts a collection to a set.static <T> String
toString
(Collection<T> c) Converts a collection to a string.
-
Method Details
-
findFirst
Iterates the elements in the specific collection, in the order they are returned by the collection's iterator, and finds the first element of given collection that satisfies the predicate. If not such element is found, returnsnull
. -
getOne
- Returns:
- an arbitrary element of the given collection.
-
append
Creates a list of given collection, appends a specific element to the list and returns it. -
sum
Maps each element in given collection to an integer and computes the sum of the integers. -
toString
Converts a collection to a string. The elements in the collection are sorted by their string representation (in alphabet order) in the resulting string. This is particularly useful for comparing expected results with the ones given by the analysis. -
toSet
Converts a collection to a set.
-