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
Post a Comment