Description
Removes the causes.
License
Apache License
Parameter
Parameter | Description |
---|
causesByDepByNameList | The list of maps with causes. |
Exception
Parameter | Description |
---|
NullPointerException | if causesByDepByNameList is null. |
Return
A new mutable list corresponding to the argument but without causes.
Declaration
public static List<SortedMap<String, SortedSet<String>>> computeGraphCauselessFromGraphLmms(
List<SortedMap<String, SortedMap<String, SortedSet<String>>>> causesByDepByNameList)
Method Source Code
//package com.java2s;
/**//from www.j a v a 2s . com
* 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.ArrayList;
import java.util.List;
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.
* List<SortedMap<name,SortedMap<dep,SortedSet<cause>>>>
* becomes List<SortedMap<name,SortedSet<dep>>>.
*
* @param causesByDepByNameList The list of maps with causes.
* @return A new mutable list corresponding to the argument but without causes.
* @throws NullPointerException if causesByDepByNameList is null.
*/
public static List<SortedMap<String, SortedSet<String>>> computeGraphCauselessFromGraphLmms(
List<SortedMap<String, SortedMap<String, SortedSet<String>>>> causesByDepByNameList) {
final List<SortedMap<String, SortedSet<String>>> reduced = new ArrayList<SortedMap<String, SortedSet<String>>>();
// Implicit null check.
for (SortedMap<String, SortedMap<String, SortedSet<String>>> causesByDepByName : causesByDepByNameList) {
// Removing causes.
final SortedMap<String, SortedSet<String>> withoutCausesMap = computeGraphCauselessFromGraphMms(causesByDepByName);
reduced.add(withoutCausesMap);
}
return reduced;
}
/**
* 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;
}
}
Related
- addMapEntry(Map> map, T1 keyEntry, T2 setEntry)
- arrayToSortedStringSet(Collection strings)
- asSortedSet(T... args)
- asSortedSet(T... elements)
- computeGraphCauselessFromGraphMms( SortedMap>> causesByDepByName)
- copyAndClearSet(SortedSet sourceSet)
- doubleForDescreteStartAndEnds(SortedSet hours)
- entriesSortedByValues( Map map)