-package org.simantics.graph.compiler.internal.procedures;\r
-\r
-import gnu.trove.list.array.TIntArrayList;\r
-import gnu.trove.map.hash.TIntIntHashMap;\r
-\r
-import org.simantics.graph.query.Paths;\r
-import org.simantics.graph.store.GraphStore;\r
-import org.simantics.graph.store.IdentityStore;\r
-\r
-public class MergeEqualResources implements Runnable {\r
-\r
- GraphStore store;\r
- Paths paths;\r
- \r
- public MergeEqualResources(Paths paths, GraphStore store) {\r
- this.paths = paths;\r
- this.store = store;\r
- }\r
-\r
- @Override\r
- public void run() {\r
- IdentityStore identities = store.identities;\r
- if(identities.contains(paths.Equals)) {\r
- int equalsId = identities.pathToId(paths.Equals);\r
- identities.removeIdentity(equalsId);\r
- TIntArrayList rel = store.statements.extractRelation(equalsId);\r
- for(int i=0;i<rel.size();i+=2)\r
- identities.unify(rel.get(i), rel.get(i+1));\r
- }\r
- \r
- TIntIntHashMap map = identities.extractUnifications();\r
- do {\r
- store.map(map); \r
- map = identities.extractUnifications();\r
- } while(!map.isEmpty());\r
- } \r
-\r
-}\r
+package org.simantics.graph.compiler.internal.procedures;
+
+import gnu.trove.list.array.TIntArrayList;
+import gnu.trove.map.hash.TIntIntHashMap;
+
+import org.simantics.graph.query.Paths;
+import org.simantics.graph.store.GraphStore;
+import org.simantics.graph.store.IdentityStore;
+
+public class MergeEqualResources implements Runnable {
+
+ GraphStore store;
+ Paths paths;
+
+ public MergeEqualResources(Paths paths, GraphStore store) {
+ this.paths = paths;
+ this.store = store;
+ }
+
+ @Override
+ public void run() {
+ IdentityStore identities = store.identities;
+ if(identities.contains(paths.Equals)) {
+ int equalsId = identities.pathToId(paths.Equals);
+ identities.removeIdentity(equalsId);
+ TIntArrayList rel = store.statements.extractRelation(equalsId);
+ for(int i=0;i<rel.size();i+=2)
+ identities.unify(rel.get(i), rel.get(i+1));
+ }
+
+ TIntIntHashMap map = identities.extractUnifications();
+ do {
+ store.map(map);
+ map = identities.extractUnifications();
+ } while(!map.isEmpty());
+ }
+
+}