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%2Fstore%2FLocationStore.java;fp=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Fstore%2FLocationStore.java;h=a6cf28987091a6d0163ef6b0f756159302a773bd;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/store/LocationStore.java b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/store/LocationStore.java new file mode 100644 index 000000000..a6cf28987 --- /dev/null +++ b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/store/LocationStore.java @@ -0,0 +1,36 @@ +package org.simantics.graph.compiler.internal.store; + +import gnu.trove.map.hash.TIntIntHashMap; +import gnu.trove.map.hash.TIntObjectHashMap; +import gnu.trove.set.hash.TIntHashSet; + +import org.simantics.graph.store.IStore; +import org.simantics.graph.store.IndexMappingUtils; +import org.simantics.ltk.Location; + +public class LocationStore implements IStore { + + TIntObjectHashMap locations; + + public LocationStore(TIntObjectHashMap locations) { + this.locations = locations; + } + + public LocationStore() { + this(new TIntObjectHashMap()); + } + + @Override + public void map(TIntIntHashMap map) { + locations = IndexMappingUtils.map(map, locations, new TIntHashSet()); + } + + public Location getLocation(int id) { + return locations.get(id); + } + + public void add(int resource, Location tree) { + locations.putIfAbsent(resource, tree); + } + +}