1
什麼是合併兩個併發地圖的最佳方式。如何合併collection.concurrent.Map
這裏是我當前的IMPL:
private def merge[A, B](map1: concurrent.Map[A, B], map2: concurrent.Map[A, B]) : concurrent.Map[A, B] = {
val mergedMap = map1 ++ map2
val concurrentMap = new TrieMap[A, B]()
mergedMap.foreach {case (k, v) => concurrentMap.put(k, v)}
concurrentMap
}