I can use Java util. Set implements state transition for DFA in Java
I am working as close as possible to formally define the implementation of DFA as a learning exercise (and blog material)
I plan to use Java util. Set, where the definition involves a set
This definition involves a set of tuples to define legal state transitions: (state, symbol) – > nextstate
I have a transition class whose members are state, symbol and nextstate I have implemented equals () and hashcode () to indicate that if two transitions match in state and symbol, they are equal Then I have a Java util. Set.
In my processing algorithm, when I read the next symbol, I have the current state I expect to use these two to build a transition object, take the matching transition from the set, and then tell me the next state that I can iterate
But – I don't see any way to extract Java util. Set for further use I can delete (object o), but only return Boolean
What on earth did I do wrong?
Solution
Set may not be what you want to use My suggestion is to use list < conversion >, or maybe map < country list, lt; Transition > replace I'm not sure which is better without actually building it and doing some benchmarking