X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Fprocedures%2FCompactify.java;fp=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Fprocedures%2FCompactify.java;h=82fd5798c09dff76c6e23db5b2979358291e8221;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/Compactify.java b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/Compactify.java new file mode 100644 index 000000000..82fd5798c --- /dev/null +++ b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/procedures/Compactify.java @@ -0,0 +1,32 @@ +package org.simantics.graph.compiler.internal.procedures; + +import gnu.trove.map.hash.TIntIntHashMap; + +import org.simantics.graph.store.GraphStore; + +public class Compactify implements Runnable { + GraphStore store; + + public Compactify(GraphStore store) { + this.store = store; + } + + @Override + public void run() { + // Mark all used resources + int resourceCount = store.identities.getResourceCount(); + final boolean[] temp = new boolean[resourceCount]; + store.collectReferences(temp); + + // Create a map + int newResourceCount = 0; + TIntIntHashMap map = new TIntIntHashMap(resourceCount); + for(int i=0;i