has_neighbour.hxx

00001 // has_neighbour.hxx: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 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_INTERNAL_HAS_NEIGHBOUR_HXX
00018 # define VCSN_ALGORITHMS_INTERNAL_HAS_NEIGHBOUR_HXX
00019 
00020 # include <vaucanson/algorithms/internal/has_neighbour.hh>
00021 
00022 namespace vcsn {
00023   // Determine wether there is at least a successor of a state.
00024   namespace internal {
00025     struct has_neighbour_helper
00026     {
00027       has_neighbour_helper () : has_neighbour_ (false) {}
00028       bool operator() (htransition_t)
00029       {
00030         this->has_neighbour_ = true;
00031         // Stop the loop over successors by returning false.
00032         return false;
00033       }
00034       bool has_neighbour_;
00035     };
00036   }
00037 
00038   template<typename A, typename T>
00039   bool  has_successors(const Element<A, T>& a,
00040                        const hstate_t s)
00041   {
00042     precondition (a.has_state (s));
00043     internal::has_neighbour_helper functor;
00044     a.deltaf (functor, s, delta_kind::transitions());
00045     return functor.has_neighbour_;
00046   }
00047 
00048   template<typename A, typename T>
00049   bool  has_predecessors(const Element<A, T>& a,
00050                          const hstate_t s)
00051   {
00052     precondition (a.has_state (s));
00053     internal::has_neighbour_helper functor;
00054     a.rdeltaf (functor, s, delta_kind::transitions());
00055     return functor.has_neighbour_;
00056   }
00057 } // vcsn
00058 
00059 #endif // ! VCSN_ALGORITHMS_INTERNAL_HAS_NEIGHBOUR_HXX

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