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

- File List
- File Members

# hash_visitor.hxx

    00001 // hash_visitor.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_ALGEBRA_IMPLEMENTATION_SERIES_RAT_HASH_VISITOR_HXX
    00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_HASH_VISITOR_HXX
    00019
    00020 # include <boost/functional/hash/hash.hpp>
    00021 # include <vaucanson/algebra/implementation/series/rat/dump_visitor.hh>
    00022 # include <vaucanson/algebra/implementation/series/rat/nodes.hh>
    00023
    00024 namespace vcsn {
    00025
    00026   namespace rat {
    00027
    00028     template <class Word, class Weight>
    00029     HashVisitor<Word, Weight>::HashVisitor()
    00030         : seed_(0)
    00031     {
    00032     }
    00033
    00034     template <class Word, class Weight>
    00035     HashVisitor<Word, Weight>::~HashVisitor()
    00036     {}
    00037
    00038     template <class Word, class Weight>
    00039     void
    00040     HashVisitor<Word, Weight>::product(const node_t* lhs, const node_t* rhs)
    00041     {
    00042       lhs->accept(*this);
    00043       ::boost::hash_combine(seed_, '.');
    00044       rhs->accept(*this);
    00045     }
    00046
    00047     template <class Word, class Weight>
    00048     void
    00049     HashVisitor<Word, Weight>::sum(const node_t* lhs, const node_t* rhs)
    00050     {
    00051       lhs->accept(*this);
    00052       ::boost::hash_combine(seed_, '+');
    00053       rhs->accept(*this);
    00054     }
    00055
    00056     template<class Word, class Weight>
    00057     void
    00058     HashVisitor<Word, Weight>::star(const node_t* node)
    00059     {
    00060       node->accept(*this);
    00061       ::boost::hash_combine(seed_, '*');
    00062     }
    00063
    00064     template<class Word, class Weight>
    00065     void
    00066     HashVisitor<Word, Weight>::left_weight(const semiring_elt_value_t& w, const node_t* node)
    00067     {
    00068       ::boost::hash_combine(seed_, w);
    00069       node->accept(*this);
    00070     }
    00071
    00072     template<class Word, class Weight>
    00073     void
    00074     HashVisitor<Word, Weight>::right_weight(const semiring_elt_value_t& w, const node_t* node)
    00075     {
    00076       ::boost::hash_combine(seed_, ' ');
    00077       ::boost::hash_combine(seed_, w);
    00078       node->accept(*this);
    00079     }
    00080
    00081     template<class Word, class Weight>
    00082     void
    00083     HashVisitor<Word, Weight>::constant(const monoid_elt_value_t& m)
    00084     {
    00085       ::boost::hash_combine(seed_, m);
    00086     }
    00087
    00088     template<class Word, class Weight>
    00089     void
    00090     HashVisitor<Word, Weight>::zero()
    00091     {
    00092       ::boost::hash_combine(seed_, rat::zero());
    00093     }
    00094
    00095     template<class Word, class Weight>
    00096     void
    00097     HashVisitor<Word, Weight>::one()
    00098     {
    00099       ::boost::hash_combine(seed_, rat::id());
    00100     }
    00101
    00102     template<class Word, class Weight>
    00103     std::size_t
    00104     HashVisitor<Word, Weight>::hash_value()
    00105     {
    00106       return seed_;
    00107     }
    00108
    00109
    00110   } // rat
    00111
    00112 } // vcsn
    00113
    00114 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_HASH_VISITOR_HXX