Commit 4418a90d authored by Alexander Frömmgen's avatar Alexander Frömmgen
Browse files

Tossa reverse VariableAssignment

parent badf8c71
...@@ -49,6 +49,11 @@ ...@@ -49,6 +49,11 @@
<artifactId>kryonet</artifactId> <artifactId>kryonet</artifactId>
<version>2.22.0-RC1</version> <version>2.22.0-RC1</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -2,6 +2,10 @@ package de.tudarmstadt.maki.simonstrator.api.component.topology; ...@@ -2,6 +2,10 @@ package de.tudarmstadt.maki.simonstrator.api.component.topology;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import de.tudarmstadt.maki.simonstrator.api.common.UniqueID; import de.tudarmstadt.maki.simonstrator.api.common.UniqueID;
import de.tudarmstadt.maki.simonstrator.api.common.graph.EdgeID; import de.tudarmstadt.maki.simonstrator.api.common.graph.EdgeID;
...@@ -13,11 +17,11 @@ import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID; ...@@ -13,11 +17,11 @@ import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID;
*/ */
public final class VariableAssignment { public final class VariableAssignment {
private final Map<INodeID, INodeID> nodeBinding; private final BiMap<INodeID, INodeID> nodeBinding;
private final Map<EdgeID, EdgeID> linkBinding; private final Map<EdgeID, EdgeID> linkBinding;
public VariableAssignment() { public VariableAssignment() {
this.nodeBinding = new HashMap<>(); this.nodeBinding = HashBiMap.create();
this.linkBinding = new HashMap<>(); this.linkBinding = new HashMap<>();
} }
...@@ -31,10 +35,18 @@ public final class VariableAssignment { ...@@ -31,10 +35,18 @@ public final class VariableAssignment {
return this.nodeBinding.get(variable); return this.nodeBinding.get(variable);
} }
public INodeID getInverseVariableBinding(final INodeID variable) {
return this.nodeBinding.inverse().get(variable);
}
public INodeID getNodeVariableBinding(final String key) { public INodeID getNodeVariableBinding(final String key) {
return nodeBinding.get(INodeID.get(key)); return nodeBinding.get(INodeID.get(key));
} }
public Set<Map.Entry<INodeID, INodeID>> getNodeBindingEntrySet() {
return nodeBinding.entrySet();
}
public void bindVariable(UniqueID variable, IElement candidate) { public void bindVariable(UniqueID variable, IElement candidate) {
if (variable instanceof INodeID) { if (variable instanceof INodeID) {
this.bindNodeVariable((INodeID) variable, (INodeID) candidate); this.bindNodeVariable((INodeID) variable, (INodeID) candidate);
...@@ -129,6 +141,4 @@ public final class VariableAssignment { ...@@ -129,6 +141,4 @@ public final class VariableAssignment {
+ "]"; + "]";
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment