I have a Map of key pair as (String,Set(Integer)). In which each entry denotes an occurrences of an element. Now what I want to do is to have a set of elements from that keys and find the occurrences where all those have simultaneously happened. The set will be incremented gradually.
I am stuck on how to form a method with Set of String and Map of String,Set-Integer as input which will return an Set of Integer as output which will contain the intersection of all integers in set in map corresponding to keys from a set of strings.
this is my map
Map<String,Set<Integer>> transactions = new HashMap<String,Set<Integer>>();
This is the Set of string
Set<String> check_set
Now question is how to make this method
Set<Integer> getIntersection(Map<String,Set<Integer>> transactions, Set<String> check_set)
Which will return intersection of all the Set of integers corresponding to the keys in set of string. I know i have to use retainAll function, but what i cant figure out is how to use it. It is a bit confusing.