- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# hash.hh

    00001 // hash_label.hh: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 2007, 2008 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
    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 <>
    00042     struct hash_label<int>
    00043     {
    00044       std::size_t operator() (const int) const;
    00045     };
    00046
    00047     template <typename U, typename V>
    00048     struct hash_label<std::pair<U, V> >
    00049     {
    00050       std::size_t operator() (const std::pair<U, V>&) const;
    00051     };
    00052
    00053     template <typename Word, typename Weight>
    00054     struct hash_label<algebra::polynom<Word, Weight> >
    00055     {
    00056       std::size_t operator() (const algebra::polynom<Word, Weight>& l) const;
    00057     };
    00058
    00059     template <typename Weight, typename T, typename U>
    00060     struct hash_label<algebra::polynom<std::pair<T, U>, Weight> >
    00061     {
    00062       std::size_t operator() (const algebra::polynom<std::pair<T, U>, Weight>& l) const;
    00063     };
    00064
    00065     template <typename Word, typename Word2, typename WeightT>
    00066     struct hash_label<algebra::polynom<Word, rat::exp<Word2, WeightT> > >
    00067     {
    00068       std::size_t operator() (const algebra::polynom<Word, rat::exp<Word2, WeightT> >& l) const;
    00069       std::size_t operator() (const rat::exp<Word2, WeightT>& l) const;
    00070     };
    00071
    00072 #if 0
    00073     template <typename Word, typename LetterT, typename WeightT>
    00074     struct hash_label<algebra::polynom<Word, rat::exp<LetterT, WeightT> > >
    00075     {
    00076       std::size_t operator() (const algebra::polynom<Word, rat::exp<LetterT, WeightT> >& l) const;
    00077     };
    00078 #endif
    00079
    00080
    00081 /*    template <typename Word, typename LetterT, typename WeightT>
    00082     struct hash_label<algebra::polynom<Word, rat::exp<std::string, rat::exp<LetterT, WeightT> > > >
    00083     {
    00084       std::size_t operator() (const algebra::polynom<Word, rat::exp<std::string, rat::exp<LetterT, WeightT > > >& l) const;
    00085     };
    00086 */
    00087     template <typename Word, typename Weight>
    00088     struct hash_label<rat::exp<Word, Weight> >
    00089     {
    00090       std::size_t operator() (const rat::exp<Word, Weight>& l) const;
    00091     };
    00092
    00093     template <typename T>
    00094     struct hash_handler;
    00095
    00096     template <typename Kind, typename Type>
    00097     struct hash_handler<handler<Kind, Type> >
    00098     {
    00099       std::size_t operator() (const handler<Kind, Type>& h) const;
    00100     };
    00101
    00102     template<>
    00103     struct hash_handler<char>
    00104     {
    00105       std::size_t operator() (const char h) const;
    00106     };
    00107
    00108     struct hash_state_handler
    00109     {
    00110       inline std::size_t operator() (const handler<state_h, std::size_t*>& h) const
    00111       {
    00112         return ::boost::hash_value (reinterpret_cast<std::size_t>(h.value()));
    00113       }
    00114
    00115       inline std::size_t operator() (const boost::shared_ptr<std::size_t>& h) const
    00116       {
    00117         return ::boost::hash_value (reinterpret_cast<std::size_t>(h.get()));
    00118       }
    00119
    00120       inline std::size_t operator() (const std::size_t* h) const
    00121       {
    00122         return ::boost::hash_value (reinterpret_cast<std::size_t>(h));
    00123       }
    00124     };
    00125
    00126   }
    00127 } // End of namespace vcsn
    00128
    00129 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
    00130 #  include <vaucanson/misc/hash.hxx>
    00131 # endif // ! VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB
    00132
    00133 #endif // ! VCSN_MISC_HASH_HH_ //