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...


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.




Nov 29, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here