Вопрос

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?

Это было полезно?

Решение

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);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top