I implement DFA as close as possible to the formal definition of a training exercise (and blog material).
I planned to use java.util.Set, where a set is involved in the definition.
The definition includes a set of tuples for determining transitions of a legal state: (state, symbol) → nextState.
I have a Transition class with member state, character, and nextState. I applied equals () and hashCode () to indicate that two transitions are equal if they match state and symbol. Then I have java.util.Set instances of Transition.
In my processing algorithm, I have the current state when I read the next character. I was expecting you to build a Transition object using these two to pull the corresponding transition from the set, which then tells me the next state, and I can iterate through it.
But - I do not see a way to extract the java.util.Set member for future use. I can delete (Object o), but that just returns boolean.
What am I doing wrong?
source
share