0

I'd like to check if there are a certain number of values for a given key within a Multimap. How would I go about doing this?

0

2 Answers 2

4

Either multimap.get(key).size() or multimap.keys().count(key) will work. If it matters, the first will probably "waste" an object instance and the second will probably not.

2

you can perform a get(key) that will return a collection, over that collection you invoke size() to find out how many elements are on the Multimap associated with the given key.

From the documentation:

Collection get(K key) Returns a collection view of all values associated with a key.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.