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     template <typename T>
00026     struct has_neighbour_helper
00027     {
00028       has_neighbour_helper () : has_neighbour_ (false) {}
00029       bool operator() (typename automaton_traits<T>::htransition_t)
00030       {
00031         this->has_neighbour_ = true;
00032         // Stop the loop over successors by returning false.
00033         return false;
00034       }
00035       bool has_neighbour_;
00036     };
00037   }
00038 
00039   template<typename A, typename T>
00040   bool  has_successors(const Element<A, T>& a,
00041                        const typename automaton_traits<T>::hstate_t s)
00042   {
00043     precondition (a.has_state (s));
00044     internal::has_neighbour_helper<T> functor;
00045     a.deltaf (functor, s, delta_kind::transitions());
00046     return functor.has_neighbour_;
00047   }
00048 
00049   template<typename A, typename T>
00050   bool  has_predecessors(const Element<A, T>& a,
00051                          const typename automaton_traits<T>::hstate_t s)
00052   {
00053     precondition (a.has_state (s));
00054     internal::has_neighbour_helper<T> functor;
00055     a.rdeltaf (functor, s, delta_kind::transitions());
00056     return functor.has_neighbour_;
00057   }
00058 } // vcsn
00059 
00060 #endif // ! VCSN_ALGORITHMS_INTERNAL_HAS_NEIGHBOUR_HXX

Generated on Thu Oct 9 20:22:35 2008 for Vaucanson by  doxygen 1.5.1