]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/store/LocationStore.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / store / LocationStore.java
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 (file)
index 0000000..a6cf289
--- /dev/null
@@ -0,0 +1,36 @@
+package org.simantics.graph.compiler.internal.store;\r
+\r
+import gnu.trove.map.hash.TIntIntHashMap;\r
+import gnu.trove.map.hash.TIntObjectHashMap;\r
+import gnu.trove.set.hash.TIntHashSet;\r
+\r
+import org.simantics.graph.store.IStore;\r
+import org.simantics.graph.store.IndexMappingUtils;\r
+import org.simantics.ltk.Location;\r
+\r
+public class LocationStore implements IStore {\r
+       \r
+       TIntObjectHashMap<Location> locations;\r
+\r
+       public LocationStore(TIntObjectHashMap<Location> locations) {\r
+               this.locations = locations;\r
+       }\r
+\r
+       public LocationStore() {\r
+               this(new TIntObjectHashMap<Location>());\r
+       }\r
+\r
+       @Override\r
+       public void map(TIntIntHashMap map) {\r
+               locations = IndexMappingUtils.map(map, locations, new TIntHashSet());\r
+       }\r
+       \r
+       public Location getLocation(int id) {\r
+               return locations.get(id);\r
+       }\r
+\r
+       public void add(int resource, Location tree) {\r
+               locations.putIfAbsent(resource, tree);          \r
+       }\r
+\r
+}\r