Class CollectionUtils

java.lang.Object
pascal.taie.util.collection.CollectionUtils

public final class CollectionUtils extends Object
Utility methods for Collection. We name it CollectionUtils instead of Collections to avoid name collision with Collections.
  • Method Details

    • findFirst

      @Nullable public 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. If not such element is found, returns null.
    • getOne

      public static <T> T getOne(Collection<T> c)
      Returns:
      an arbitrary element of the given collection.
    • append

      public static <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.
    • sum

      public 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.
    • toString

      public static <T> String toString(Collection<T> c)
      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

      public static <T> Set<T> toSet(Collection<T> c)
      Converts a collection to a set.