1 package org.simantics.graph.compiler.internal.templates;
3 import gnu.trove.map.hash.TIntIntHashMap;
4 import gnu.trove.map.hash.TIntObjectHashMap;
5 import gnu.trove.procedure.TIntObjectProcedure;
6 import gnu.trove.procedure.TObjectProcedure;
7 import gnu.trove.set.hash.TIntHashSet;
9 import org.simantics.graph.store.IStore;
10 import org.simantics.graph.store.IndexMappingUtils;
12 public class TemplateDefinitionStore implements IStore {
13 TIntObjectHashMap<TemplateDefinition> templateDefinitions;
14 TIntHashSet collisions = new TIntHashSet();
16 public TemplateDefinitionStore(TIntObjectHashMap<TemplateDefinition> templateDefinitions) {
17 this.templateDefinitions = templateDefinitions;
20 public TemplateDefinitionStore() {
21 this(new TIntObjectHashMap<TemplateDefinition>());
25 public void map(final TIntIntHashMap map) {
26 templateDefinitions = IndexMappingUtils.map(map, templateDefinitions, collisions);
27 templateDefinitions.forEachValue(new TObjectProcedure<TemplateDefinition>() {
29 public boolean execute(TemplateDefinition template) {
36 public void forTemplateDefinitions(TIntObjectProcedure<TemplateDefinition> proc) {
37 templateDefinitions.forEachEntry(proc);
40 public void add(int subject, TemplateDefinition templateDefinition) {
41 templateDefinitions.put(subject, templateDefinition);
44 public boolean isEmpty() {
45 return templateDefinitions.isEmpty();
48 public TIntHashSet getCollisions() {