]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/store/LocationStore.java
3c3799bf7561f536f030873ffef1237a4ab91c3a
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / store / LocationStore.java
1 package org.simantics.graph.compiler.internal.store;
2
3 import gnu.trove.map.hash.TIntIntHashMap;
4 import gnu.trove.map.hash.TIntObjectHashMap;
5 import gnu.trove.set.hash.TIntHashSet;
6
7 import org.simantics.graph.store.IStore;
8 import org.simantics.graph.store.IndexMappingUtils;
9 import org.simantics.ltk.Location;
10
11 public class LocationStore implements IStore {
12         
13         TIntObjectHashMap<Location> locations;
14
15         public LocationStore(TIntObjectHashMap<Location> locations) {
16                 this.locations = locations;
17         }
18
19         public LocationStore() {
20                 this(new TIntObjectHashMap<Location>());
21         }
22
23         @Override
24         public void map(TIntIntHashMap map) {
25                 locations = IndexMappingUtils.map(map, locations, new TIntHashSet());
26         }
27         
28         public Location getLocation(int id) {
29                 return locations.get(id);
30         }
31
32         public void add(int resource, Location tree) {
33                 locations.putIfAbsent(resource, tree);          
34         }
35
36 }