java - In Guava, how to create a Multiset with a single element and n occurrences -


i'd create (immutable) multiset in guava has single entry element occurrences occurrences, both of not known @ compile time.

what i've come this:

immutablemultiset.<x>builder().addcopies(element, occurrences).build() 

i guess looking method this:

public static immutablemultiset<x> immutablemultiset.noccurrencesof( x element, int occurrences){} 

or:

public static immutablemultiset<x> multisets.singletonmultiset( x element, int occurrences){} 

is there method have overlooked makes above code shorter?

guava contributor here.

stick builder. addresses problem quite simply, , in single line; it's not common enough case require own special method.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -