回答你的情況不會工作,將工作只有額外的(鍵,值)對在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'。 –