回答你的情况不会工作,将工作只有额外的(键,值)对在MapA中。像MapA = {1“ - > [”a“,”b“]”2“ - > [”c“,”d“]}和MapB = {1” - > [“a”,“b”] }。
什么ü需要的是这个 -
boolean isStrictlyDominate(LinkedHashMap<Integer, HashSet<Integer>> firstMap, LinkedHashMap<Integer, HashSet<Integer>> secondMap){
for (Map.Entry<Integer, HashSet<Integer>> item : secondMap.entrySet()) {
int secondMapKey = item.getKey();
if(firstMap.containsKey(secondMapKey)) {
HashSet<Integer> secondMapValue = item.getValue();
HashSet<Integer> firstMapValue = firstMap.get(secondMapKey) ;
if(!firstMapValue.containsAll(secondMapValue)) {
return false;
}
}
}
return !firstMap.equals(secondMap);
}
(如果你不想检查严格统治那么就return
最后return
说法正确)
只为你的未来的自己的理智,不叫它比较。你没有比较。称之为'containsAll'或'subsumes'。 –