Question: A MultiSet is like a Set, but allows duplicates. Consider the following interface for a MultiSet:
public interface MultiSet
{
void add( AnyType x );
boolean contains( AnyType x );
int count( AnyType x );
boolean removeOne( AnyType x );
boolean removeAll( AnyType x );
void toArray( AnyType [] arr );
}
There are many ways to implement the MultiSet interface. A TreeMultiSet stores items in sorted order. The data representation can be a TreeMap, in which the key is an item that is in the multiset, and the value represents the number of times the item is stored. Implement the TreeMultiSet, and make sure toString is provided.