A MultiSet is like a Set, but allows duplicates. Consider an implementation that uses a Map, in which the value represents a count of the number of duplicates. However, that implementation loses information. For instance if we add a BigDecimal representing 4.0 and another BigDecimal representing 4.000 (note that for these two objects, compareTo yields 0, but equals yields false), the first occurrence will be inserted with a count of 2, and toString will necessarily lose information about 4.000 being in the multiset. Consequently, an alternative implementation would be to use a Map, in which the value represents a list of all additional instances of the key. Write a complete implementation of the MultiSet, and test it by adding several logically equal BigDecimals.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here