Vcsn  2.3
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  auto \
11  hash<ExpSet>
12 
13 #define VISIT(Type) \
14  DEFINE::visit(const Type ## _t& v) \
15  -> void
16 
17 
18  VISIT(atom)
19  {
20  visit_(v);
21  hash_combine(res_, ExpSet::labelset_t::hash(v.value()));
22  }
23 
24  VISIT(lweight)
25  {
26  visit_(v);
27  }
28 
29  VISIT(rweight)
30  {
31  visit_(v);
32  }
33 
34  template <typename ExpSet>
35  void
37  {
38  hash_combine(res_, int(node.type()));
39  }
40 
41  template <typename ExpSet>
42  void
44  {
45  combine_type(n);
46  }
47 
48  template <typename ExpSet>
49  template <type_t Type>
50  void
52  {
53  combine_type(n);
54  n.sub()->accept(*this);
55  }
56 
57  template <typename ExpSet>
58  template <type_t Type>
59  void
61  {
62  combine_type(n);
63  hash_combine(res_, ExpSet::weightset_t::hash(n.weight()));
64  n.sub()->accept(*this);
65  }
66 
67  template <typename ExpSet>
68  template <type_t Type>
69  void
71  {
72  combine_type(n);
73  for (const auto& child : n)
74  child->accept(*this);
75  }
76 #undef VISIT
77 #undef DEFINE
78 
79  } // namespace rat
80 } // namespace vcsn
return v
Definition: multiply.hh:361
typename super_t::template unary_t< Type > unary_t
Definition: hash.hh:28
The abstract parameterized, root for all rational expression types.
Definition: expression.hh:80
typename super_t::template weight_node_t< Type > weight_node_t
Definition: hash.hh:30
typename super_t::template variadic_t< Type > variadic_t
Definition: hash.hh:26
void combine_type(const node_t &node)
Update res_ by hashing the node type; this is needed for any node.
Definition: hash.hxx:36
weight_node< type_t::rweight, Context > rweight
Definition: fwd.hh:182
typename super_t::node_t node_t
Actual node, without indirection.
Definition: hash.hh:20
Definition: a-star.hh:8
#define VISIT(Type)
Definition: hash.hxx:13
void hash_combine(std::size_t &seed, const T &v)
Definition: functional.hh:48
void visit_(const node_t &v)
Traverse a nullary node (atom, \z, \e).
Definition: hash.hxx:43
weight_node< type_t::lweight, Context > lweight
Definition: fwd.hh:179