Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static <T, U> void mapMergeRemove(Map<T, List<U>> map, Map<T, List<U>> mapToRemove) {
        for (Map.Entry<T, List<U>> e : mapToRemove.entrySet()) {
            if (map.containsKey(e.getKey())) {
                map.get(e.getKey()).removeAll(e.getValue());
                if (map.get(e.getKey()).isEmpty()) {
                    map.remove(e.getKey());
                }
            }
        }
    }
}