import java.util.*; public class Debugging { public static void main(String[] args) { Map> testMap = new TreeMap<>(); Set c121 = arrToSet(new int[]{42, 17, 42, 42}); Set c122 = arrToSet(new int[]{10, 12, 14}); Set c123 = arrToSet(new int[]{100, 99, 98, -97}); testMap.put("cse121", c121); testMap.put("cse122", c122); testMap.put("cse123", c123); Map> deepCopyMap = deepCopy(testMap); if (deepCopyMap.isEmpty()) { System.out.println("{}"); } else { String line = ""; for (String key : deepCopyMap.keySet()) { line += key + "=" + deepCopyMap.get(key).toString() + ", "; } System.out.println("{" + line.substring(0, line.length() - 2) + "}"); } } public static Set arrToSet(int[] arr) { Set s = new TreeSet<>(); for (int num : arr) { s.add(num); } return s; } // Produces and returns a "deep copy" of the parameter map, which has the same // structure and values as the parameter, but with all internal data structures // and values copied. After calling this method, modifying the parameter or // return value should NOT affect the other. // // Parameters: // inputMap - the map to duplicate // // Returns: // A deep copy of the parameter map. public static Map> deepCopy(Map> inputMap) { Map> deepCopy = new TreeMap<>(); for (String key : inputMap.keySet()) { Set inputSet = new TreeSet<>(inputMap.get(key)); // Set inputSet = inputMap.get(key); deepCopy.put(key, inputSet); } return deepCopy; } }