complement.hxx

00001 // complement.hxx: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2001, 2002, 2003, 2004 The Vaucanson Group.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
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/tools/usual_macros.hh>
00028 # include <vaucanson/misc/contract.hh>
00029 
00030 namespace vcsn {
00031 
00032   /*----------------.
00033   | Complement_here |
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_each_state(i, e)
00045       if (e.is_final(*i))
00046         e.unset_final(*i);
00047       else
00048         e.set_final(*i);
00049   }
00050 
00051   /*----------------.
00052   | Complement_here |
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 } // vcsn
00065 
00066 #endif // ! VCSN_ALGORITHMS_COMPLEMENT_HXX

Generated on Fri Jul 28 12:18:30 2006 for Vaucanson by  doxygen 1.4.6