Question: Create a class named MapSet and use it to implement your generic Set interface using a HashMap. a . Your constructor should create an empty
Create a class named MapSet and use it to implement your generic Set interface using a HashMap.
a Your constructor should create an empty HashMap. Use the Set's type paratemer as the key type in the map. The value type does not matter use any type you'd like.
b When an element is added to the set, add it to the map as a key. Again, the value does not matter, so use null.
c Use the other methods on the HashMap to implement the remaining methods in your set interface.
d Write a unit test to verify that your Set works as expected, including iterating over the elements using a for loop. Hint: just return the iterator for the key set.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
