에서의 HashMap의 조회 나는과 같이, 다차원 HashMaps을 가진 세트를 가지고 :자바 저장 및 HashSet의
Set<HashMap<String, HashMap<String, String>>> myHashSet = new HashSet<HashMap<String, HashMap<String, String>>>();
나는 문제는 HashMap의 항목을 제거하는 데. 최상위 해시 맵의 키를 알고 있지만 기본 해시 맵의 데이터를 모릅니다. 나는이 방법으로 세트의 해시 맵 항목을 제거하려고 :
I.
Set<HashMap<String, HashMap<String, String>>> myHashSet = new HashSet<HashMap<String, HashMap<String, String>>>();
... Add some hashmaps to the set, then ...
String myKey = "target_key";
setInQuestion.remove(myKey);
II.
Set<HashMap<String, HashMap<String, String>>> myHashSet = new HashSet<HashMap<String, HashMap<String, String>>>();
... Add some hashmaps to the set, then ...
String myKey = "key_one"; //Assume a hashmap has been added with this top level key
HashMap<String, HashMap<String, String>> removeMap = new HashMap<String, HashMap<String, String>>();
HashMap<String, String> dummyMap = new HashMap<String, String>();
removeMap.put(myKey, dummyMap);
setInQuestion.remove(removeMap);
이러한 방법 중 어느 것도 작동하지 않습니다. 최상위 해시 맵의 키만 알고있는 경우 집합의 항목을 제거하는 방법은 무엇입니까?
실제로 ConcurrentModificationException이 발생합니다. 대신에,'mySetIterator.remove()'를 사용하십시오. – jtahlborn