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, 2005, 2006 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/is_deterministic.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   | complement_here.  |
00034   `------------------*/
00035 
00036   template <typename A, typename T>
00037   void
00038   complement_here(Element<A, T>& e)
00039   {
00040     TIMER_SCOPED("complement");
00041     typedef Element<A, T> automaton_t;
00042     AUTOMATON_TYPES(automaton_t);
00043 
00044     precondition(is_complete(e) && is_deterministic(e));
00045     for_all_states(i, e)
00046       if (e.is_final(*i))
00047         e.unset_final(*i);
00048       else
00049         e.set_final(*i);
00050   }
00051 
00052   /*-------------.
00053   | complement.  |
00054   `-------------*/
00055 
00056   template <typename A, typename T>
00057   Element<A, T>
00058   complement(const Element<A, T>& e)
00059   {
00060     Element<A, T> res(e);
00061     complement_here(res);
00062     return res;
00063   }
00064 
00065 } // vcsn
00066 
00067 #endif // ! VCSN_ALGORITHMS_COMPLEMENT_HXX

Generated on Sun Jul 29 19:35:18 2007 for Vaucanson by  doxygen 1.5.2