Class CollectionUtils


  • public class CollectionUtils
    extends Object
    • Constructor Detail

      • CollectionUtils

        public CollectionUtils()
    • Method Detail

      • intersection

        public static Collection intersection​(Collection a,
                                              Collection b)
        Returns a Collection containing the intersection of the given Collections.

        The cardinality of each element in the returned Collection will be equal to the minimum of the cardinality of that element in the two given Collections.

        Parameters:
        a - the first collection, must not be null
        b - the second collection, must not be null
        Returns:
        the intersection of the two collections
      • getCardinalityMap

        public static Map getCardinalityMap​(Collection coll)
        Returns a Map mapping each unique element in the given Collection to an Integer representing the number of occurrences of that element in the Collection.

        Only those elements present in the collection will appear as keys in the map.

        Parameters:
        coll - the collection to get the cardinality map for, must not be null
        Returns:
        the populated cardinality map