D
Daniel Suen
Hi All,
I am trying to implement various kinds of finite automaton simulators; I
have abstract the transition mappings to be from a "Set" to another "Set"
taking on some "Input". I come up with the data structure like the following
to represent automatons,
map<Set, map<Input, Set> >
However, for deterministic finite automaton, I derive the class "State" from
the class "Set", and the class "Symbol" from the class "Input". Now, I want
to write a function that takes a string and run the automaton against the
string. Therefore, for deterministic finite automaton, the signature of the
function would be,
run(string s, map<State, map<Symbol, State> >);
I am wondering if there is any way for me to write something like the
following,
run(string s, map<Set, map<Input, Set> >);
so that I can pass different kinds of automaton representation to the
function.
If I am not on the right track in the design, could someone point me out how
I should structure the whole thing to make the code look beautiful?
-Daniel.
I am trying to implement various kinds of finite automaton simulators; I
have abstract the transition mappings to be from a "Set" to another "Set"
taking on some "Input". I come up with the data structure like the following
to represent automatons,
map<Set, map<Input, Set> >
However, for deterministic finite automaton, I derive the class "State" from
the class "Set", and the class "Symbol" from the class "Input". Now, I want
to write a function that takes a string and run the automaton against the
string. Therefore, for deterministic finite automaton, the signature of the
function would be,
run(string s, map<State, map<Symbol, State> >);
I am wondering if there is any way for me to write something like the
following,
run(string s, map<Set, map<Input, Set> >);
so that I can pass different kinds of automaton representation to the
function.
If I am not on the right track in the design, could someone point me out how
I should structure the whole thing to make the code look beautiful?
-Daniel.