00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VCSN_MISC_HASH_HH_
00019 # define VCSN_MISC_HASH_HH_
00020
00021 # include <cstddef>
00022 # include <vaucanson/algebra/implementation/series/polynoms.hh>
00023 # include <vaucanson/algebra/implementation/series/rat/exp.hh>
00024 # include <vaucanson/automata/concept/handlers.hh>
00025 # include <boost/functional/hash/hash.hpp>
00026 # include <boost/shared_ptr.hpp>
00027
00028 namespace vcsn
00029 {
00030 namespace misc
00031 {
00032 template <typename T>
00033 struct hash_label;
00034
00035 template <>
00036 struct hash_label<char>
00037 {
00038 std::size_t operator() (const char) const;
00039 };
00040
00041 template <typename Word, typename Weight>
00042 struct hash_label<algebra::polynom<Word, Weight> >
00043 {
00044 std::size_t operator() (const algebra::polynom<Word, Weight>& l) const;
00045 };
00046
00047 template <typename Weight, typename T, typename U>
00048 struct hash_label<algebra::polynom<std::pair<T, U>, Weight> >
00049 {
00050 std::size_t operator() (const algebra::polynom<std::pair<T, U>, Weight>& l) const;
00051 };
00052
00053 template <typename Word, typename WeightT>
00054 struct hash_label<algebra::polynom<Word, rat::exp<std::string, WeightT> > >
00055 {
00056 std::size_t operator() (const algebra::polynom<Word, rat::exp<std::string, WeightT> >& l) const;
00057 std::size_t operator() (const rat::exp<std::string, WeightT>& l) const;
00058
00059 };
00060
00061 template <typename Word, typename LetterT, typename WeightT>
00062 struct hash_label<algebra::polynom<Word, rat::exp<LetterT, WeightT> > >
00063 {
00064 std::size_t operator() (const algebra::polynom<Word, rat::exp<LetterT, WeightT> >& l) const;
00065 };
00066
00067
00068
00069
00070
00071
00072
00073
00074 template <typename Word, typename Weight>
00075 struct hash_label<rat::exp<Word, Weight> >
00076 {
00077 std::size_t operator() (const rat::exp<Word, Weight>& l) const;
00078 };
00079
00080 template <typename T>
00081 struct hash_handler;
00082
00083 template <typename Kind, typename Type>
00084 struct hash_handler<handler<Kind, Type> >
00085 {
00086 std::size_t operator() (const handler<Kind, Type>& h) const;
00087 };
00088
00089 template<>
00090 struct hash_handler<char>
00091 {
00092 std::size_t operator() (const char h) const;
00093 };
00094
00095 struct hash_state_handler
00096 {
00097 inline std::size_t operator() (const handler<state_h, std::size_t*>& h) const
00098 {
00099 return ::boost::hash_value (reinterpret_cast<std::size_t>(h.value()));
00100 }
00101
00102 inline std::size_t operator() (const boost::shared_ptr<std::size_t>& h) const
00103 {
00104 return ::boost::hash_value (reinterpret_cast<std::size_t>(h.get()));
00105 }
00106
00107 inline std::size_t operator() (const std::size_t* h) const
00108 {
00109 return ::boost::hash_value (reinterpret_cast<std::size_t>(h));
00110 }
00111 };
00112
00113 }
00114 }
00115
00116 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00117 # include <vaucanson/misc/hash.hxx>
00118 # endif // ! VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB
00119
00120 #endif // ! VCSN_MISC_HASH_HH_ //