]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/HierarchyMultiMap.java
Added transient caching for BrowseContext construction
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / HierarchyMultiMap.java
index a4ac87b50d1472d02626647145e6c412905aa7b6..b12d5ad2b9b4ab9d2f7d74733a2ebfe1fae21b71 100644 (file)
@@ -37,7 +37,28 @@ public abstract class HierarchyMultiMap<A,B> {
         bs.add(b);
         cache = null;
     }
-    
+
+    /**
+     * Appends the contents of the specified map to this map.
+     * 
+     * @param from the map to append contents from
+     */
+    public void append(HierarchyMultiMap<A,B> from) {
+        from.appendTo(this);
+    }
+
+    /**
+     * Appends the contents of this map to the specified map.
+     * 
+     * @param to the map to append to
+     */
+    public void appendTo(HierarchyMultiMap<A,B> to) {
+        map.forEachEntry((a, bl) -> {
+            bl.forEach(b -> to.put(a, b));
+            return true;
+        });
+    }
+
     /**
      * Gets the values stored into the map for the key {@code a} or
      * its superelements.