Next: Warning
Up: Basic Algorithms
Previous: Basic Algorithms
You may wish to implement the following statement applying any function f
to the final states of an automaton :
For each such that do f(q);
Here is the C++ code :
#include "dfa_matrix.hh"
#include "tag.hh"
#include "alphabet.hh"
main()
{
typedef DFA_matrix<Range_alphabet<char, 'a', 'z'>, STag> DFA_type;
DFA_type dfa;
// Construct the automaton
// .......
// Then apply function f to final states
DFA_type::iterator q, last;
last = dfa.end();
for(q = dfa.begin(); q != finish; ++q)
if (dfa.tag(*q).final() == true)
f(*q);
}
Vincent Lemaout
12/9/1997