刪除重複我試圖從的ArrayList與流行的技術去除重複:從ArrayList的問題
yourList = new ArrayList<String>(new LinkedHashSet<String>(yourList));
它的工作原理,但由於該ArrayList是在HashMap中我得到了這個問題。
private void removeDuplicate(HashMap<String, ArrayList<LinkedList<String>>> p)
{
//cycle for each entry of HashMap
for(Map.Entry<String, ArrayList<LinkedList<String>>> entry : p.entrySet())
{
ArrayList<LinkedList<String>> partitions = entry.getValue();
partitions = new ArrayList<LinkedList<String>>(new LinkedHashSet<LinkedList<String>>(partitions));
}
}
問題是在那之後,HashMap和以前一樣! 變量分區不再有重複,但整個HashMap不變。 問題在哪裏?
你如何匹配'分區'與哈希圖? – XtremeBaumer