Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Main {
    /**
     * @param map map
     * @return map deep copy
     */
    public static Map<String, Set<String>> cloneMap(Map<String, Set<String>> map) {
        final Map<String, Set<String>> clone = new HashMap<>(map.size());
        for (Map.Entry<String, Set<String>> entry : map.entrySet()) {
            final Set<String> cloneSet = new HashSet<>(entry.getValue());
            clone.put(entry.getKey(), cloneSet);
        }

        return clone;
    }
}