Search code examples
javafinite-automatadfaautomata

Which are the best ways to implement a DFA?


I know that DFA can be implemented using if-else approach and graph approach, but is there any other way of implementing them? Actually I am creating a JavaCode Generator for regular expressions, so far I have done two possible approaches (if-else, and graph approach) but I want to provide more possible ways. I think maybe it can be implemented using a some data structures as Set or Map for transitions.


Solution

  • Here is another way of implementing Automata, using enum. Seems cool.

    http://java.dzone.com/articles/automaton-implementation-java

    So as a conclusion I have made, there are 4 ways of implementing FSA: enum, if-else, switch case, graph, hashMap