Why aren't SortedMultiset in Google collections?

The Google Collections contains an interface Multisetand a class TreeMultiset, but I was surprised to find that there are no matching ones SortedMultiset.

Something like this would be very useful for modeling discrete probability distributions.

Before I try to implement it myself, I would like to know if there is any specific reason for its exclusion, for example. probable violation of invariants Multisetor Collectionor inherent performance problems, etc.


Edit : I did not understand this from the beginning, but actually these are three separate requests:

  • Changing the return type of one method ( TreeMultiset.entrySet)
  • New interface to match existing features TreeMultiset
  • A new pair of methods for summing counters in tree branches
+4
source share
2 answers

I think it's just that no one else needed it, so we haven't recorded it yet. This is what I consider.

+7
source

TreeMultiset.elementSet () returns a SortedSet, which can provide some necessary functions.

ETA: finnw, the SortedMultiset methods you request do not provide a much faster answer to the question "how many elements in my multiset are less than 42?" TreeMultiset implementations will still have to iterate over multiple entries and summarize the counts of the corresponding elements.

0
source

All Articles