1 package org.simantics.graph.compiler.internal.procedures;
3 import gnu.trove.list.array.TIntArrayList;
4 import gnu.trove.map.hash.TIntIntHashMap;
6 import org.simantics.graph.query.Paths;
7 import org.simantics.graph.store.GraphStore;
8 import org.simantics.graph.store.IdentityStore;
10 public class MergeEqualResources implements Runnable {
15 public MergeEqualResources(Paths paths, GraphStore store) {
22 IdentityStore identities = store.identities;
23 if(identities.contains(paths.Equals)) {
24 int equalsId = identities.pathToId(paths.Equals);
25 identities.removeIdentity(equalsId);
26 TIntArrayList rel = store.statements.extractRelation(equalsId);
27 for(int i=0;i<rel.size();i+=2)
28 identities.unify(rel.get(i), rel.get(i+1));
31 TIntIntHashMap map = identities.extractUnifications();
34 map = identities.extractUnifications();
35 } while(!map.isEmpty());