package automaton; import java.util.HashMap; import java.util.Map; public class DeterministicAutomaton { private State initialState = null; /* * In the map transitions, at each state s we associate a map m where the * values are the transitions having s as source and the corresponding key * the labels of the transitions. * */ private final Map> transitions; public DeterministicAutomaton(Transition... transitions) { this.transitions = new HashMap>(); for (Transition t : transitions) { addState(t.source()); addState(t.target()); Map map = this.transitions.get(t.source()); map.put(t.label(), t); } } protected final void addState(State s) { if (!transitions.containsKey(s)) { transitions.put(s, new HashMap()); if (s.initial()) { if (initialState == null) { initialState = s; } } } } }