next up previous
Next: Warning Up: Basic Algorithms Previous: Basic Algorithms

Iteration on Q

You may wish to implement the following statement  applying any function f to the final states of an automaton :

For each $q \in Q$ such that $q \in F$ do f(q);

Here is the C++ code :
#include "dfa_matrix.hh"
#include "tag.hh"
#include "alphabet.hh"

  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)


Vincent Lemaout