I have a guava HashMultimap like this
Multimap<String, String> multiMap = HashMultimap.create();
multiMap.put("a", "x");
multiMap.put("a", "y");
multiMap.put("b", "y");
multiMap.put("b", "z");
multiMap.put("d", "x");
multiMap.put("c", "h");
and I want to create a table with the distinct key and values. Calling
multiMap.values(); // returns x,y,y,z,x,h
but I want to the distinct set of values?.
I’m aware that Iterator.filter() is available but am unsure how it should be implmented. The expected result should be
// x,y,z,h
I’d just use
or, if you want an immutable version:
Note that in either case you no longer have a live view of the values but a copy.