문제

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