Google Collections contains the Multiset
interface and the TreeMultiset
class, but I was surprised to find that there is no corresponding SortedMultiset
interface.
Something like that would be very useful for modelling discrete probability distributions.
Before I attempt to implement it myself, I would like to know if there is a specific reason for leaving it out, e.g. likely violation of Multiset
or Collection
invariants, or inherent performance problems etc.
Edit: I didn't realise it originally but this is actually 3 separate requests:
- A change to the return type of one method (
TreeMultiset.entrySet
) - An new interface to match the existing functionality of
TreeMultiset
- A new pair of methods to sum the counts in branches of the tree