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