Question

i have two hashmultimaps . how do i compare the values of the multimap for a given key.

i thought i would generate a TreeSet from HashMultiMap something like
ts1=new TreeSet(hmap.get(key)) ts2=new TreeSet(hmap.get(key))

and then iterate over one tree set and then check if that element is there in the other tree set.

Is there a java class that generates a sorted array given a collection?

Was it helpful?

Solution

Set<Foo> a = multimap1.get(key);
Set<Foo> b = multimap2.get(key);

Set<Foo> inAButNotInB = Sets.difference(a, b);
Set<Foo> inBButNotInA = Sets.difference(b, a);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top