Here you can find the source of computeGraphCauselessFromGraphMms( SortedMap
Parameter | Description |
---|---|
causesByDepByName | The map with causes. |
Parameter | Description |
---|---|
NullPointerException | if causesByDepByName is null. |
public static SortedMap<String, SortedSet<String>> computeGraphCauselessFromGraphMms( SortedMap<String, SortedMap<String, SortedSet<String>>> causesByDepByName)
//package com.java2s; /**// w ww. j a v a2 s .c om * Copyright 2015 Jeff Hain * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Map; import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; public class Main { /** * Removes the causes. * SortedMap<name,SortedMap<dep,SortedSet<cause>>> * becomes SortedMap<name,SortedSet<dep>>. * * @param causesByDepByName The map with causes. * @return A new mutable map corresponding to the argument but without causes. * @throws NullPointerException if causesByDepByName is null. */ public static SortedMap<String, SortedSet<String>> computeGraphCauselessFromGraphMms( SortedMap<String, SortedMap<String, SortedSet<String>>> causesByDepByName) { final SortedMap<String, SortedSet<String>> reduced = new TreeMap<String, SortedSet<String>>(); // Implicit null check. for (Map.Entry<String, SortedMap<String, SortedSet<String>>> entry : causesByDepByName .entrySet()) { final String name = entry.getKey(); final SortedMap<String, SortedSet<String>> causesByDep = entry .getValue(); // Removing causes. final SortedSet<String> deps = new TreeSet<String>( causesByDep.keySet()); final Object forCheck = reduced.put(name, deps); if (forCheck != null) { throw new AssertionError(); } } return reduced; } }