00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_ALGORITHMS_COMPLEMENT_HXX
00018 # define VCSN_ALGORITHMS_COMPLEMENT_HXX
00019
00020 # include <vaucanson/algorithms/complement.hh>
00021
00022 # ifndef NDEBUG
00023 # include <vaucanson/algorithms/complete.hh>
00024 # include <vaucanson/algorithms/determinize.hh>
00025 # endif // NDEBUG
00026
00027 # include <vaucanson/misc/usual_macros.hh>
00028 # include <vaucanson/misc/contract.hh>
00029
00030 namespace vcsn {
00031
00032
00033
00034
00035
00036 template <typename A, typename T>
00037 void
00038 complement_here(Element<A, T>& e)
00039 {
00040 typedef Element<A, T> automaton_t;
00041 AUTOMATON_TYPES(automaton_t);
00042
00043 precondition(is_complete(e) && is_deterministic(e));
00044 for_all_states(i, e)
00045 if (e.is_final(*i))
00046 e.unset_final(*i);
00047 else
00048 e.set_final(*i);
00049 }
00050
00051
00052
00053
00054
00055 template <typename A, typename T>
00056 Element<A, T>
00057 complement(const Element<A, T>& e)
00058 {
00059 Element<A, T> work(e);
00060 complement_here(work);
00061 return work;
00062 }
00063
00064 }
00065
00066 #endif // ! VCSN_ALGORITHMS_COMPLEMENT_HXX