Reputation: 540
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?
Upvotes: 0
Views: 1935
Reputation: 40851
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.
Upvotes: 4
Reputation: 23903
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.
Upvotes: 2