Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hash.hxx
Go to the documentation of this file.
1 #ifndef VCSN_CORE_RAT_HASH_HXX
2 # define VCSN_CORE_RAT_HASH_HXX
3 
4 # include <vcsn/misc/hash.hh>
5 
6 namespace vcsn
7 {
8  namespace rat
9  {
10 
11 # define DEFINE \
12  template <typename RatExpSet> \
13  inline \
14  auto \
15  hash<RatExpSet>
16 
17 # define VISIT(Type) \
18  DEFINE::visit(const Type ## _t& v) \
19  -> void
20 
21 
23  {
24  visit_nullary(v);
25  std::hash_combine(res_, RatExpSet::labelset_t::hash(v.value()));
26  }
27 
29  {
30  visit_weight_node(v);
31  }
32 
34  {
35  visit_weight_node(v);
36  }
37 
38  template <typename RatExpSet>
39  inline
40  void
42  {
43  std::hash_combine(res_, int(node.type()));
44  }
45 
46  template <typename RatExpSet>
47  inline
48  void
50  {
51  combine_type(n);
52  }
53 
54  template <typename RatExpSet>
55  template <type_t Type>
56  inline
57  void
59  {
60  combine_type(n);
61  n.sub()->accept(*this);
62  }
63 
64  template <typename RatExpSet>
65  template <type_t Type>
66  inline
67  void
69  {
70  combine_type(n);
71  std::hash_combine(res_, RatExpSet::weightset_t::hash(n.weight()));
72  n.sub()->accept(*this);
73  }
74 
75  template <typename RatExpSet>
76  template <type_t Type>
77  inline
78  void
80  {
81  combine_type(n);
82  for (auto child : n)
83  child->accept(*this);
84  }
85 # undef VISIT
86 # undef DEFINE
87 
88  } // namespace rat
89 } // namespace vcsn
90 
91 #endif // !VCSN_CORE_RAT_HASH_HXX
void visit_variadic(const variadic_t< Type > &v)
Traverse an n-ary node (+, concatenation, &, :).
Definition: hash.hxx:79
void combine_type(const node_t &node)
Update res_ by hashing the node type; this is needed for any node.
Definition: hash.hxx:41
The abstract parameterized, root for all rational expression types.
Definition: fwd.hh:80
typename super_t::template variadic_t< Type > variadic_t
Definition: hash.hh:24
typename super_t::template unary_t< Type > unary_t
Definition: hash.hh:26
void visit_nullary(const node_t &v)
Traverse a nullary node (atom, \z, \e).
Definition: hash.hxx:49
void visit_weight_node(const weight_node_t< Type > &v)
Traverse a weight node (lweight, rweight).
Definition: hash.hxx:68
An inner node implementing a weight.
Definition: fwd.hh:145
#define VISIT(Type)
Definition: hash.hxx:17
void visit_unary(const unary_t< Type > &v)
Traverse a unary node (*, {c}).
Definition: hash.hxx:58
typename super_t::node_t node_t
Definition: hash.hh:21
typename super_t::template weight_node_t< Type > weight_node_t
Definition: hash.hh:28