12
12
#include < cstdlib> // for size_t
13
13
#include < vector>
14
14
15
+ #include " irep_hash.h"
15
16
#include " numbering.h"
16
17
17
18
class irept ;
18
19
19
20
class irep_hash_container_baset
20
21
{
21
22
public:
22
- unsigned number (const irept &irep);
23
+ size_t number (const irept &irep);
23
24
24
- irep_hash_container_baset (bool _full):full(_full)
25
+ explicit irep_hash_container_baset (bool _full):full(_full)
25
26
{
26
27
}
27
28
@@ -36,33 +37,34 @@ class irep_hash_container_baset
36
37
37
38
// this is the first level: address of the content
38
39
39
- struct pointer_hash
40
+ struct pointer_hasht
40
41
{
41
42
inline size_t operator ()(const void *p) const
42
43
{
43
44
return (size_t )p;
44
45
}
45
46
};
46
47
47
- typedef std::unordered_map<const void *, unsigned , pointer_hash> ptr_hasht;
48
+ typedef std::unordered_map<const void *, size_t , pointer_hasht>
49
+ ptr_hasht;
48
50
ptr_hasht ptr_hash;
49
51
50
52
// this is the second level: content
51
53
52
- typedef std::vector<unsigned > packedt;
54
+ typedef std::vector<size_t > packedt;
53
55
54
- struct vector_hash
56
+ struct vector_hasht
55
57
{
56
58
inline size_t operator ()(const packedt &p) const
57
59
{
58
- size_t result=p.size ();
59
- for (unsigned i= 0 ; i<p. size (); i++ )
60
- result^=p[i]<<i ;
60
+ size_t result=p.size (); // seed
61
+ for (auto elem : p )
62
+ result= hash_combine (result, elem) ;
61
63
return result;
62
64
}
63
65
};
64
66
65
- typedef hash_numbering<packedt, vector_hash > numberingt;
67
+ typedef hash_numbering<packedt, vector_hasht > numberingt;
66
68
numberingt numbering;
67
69
68
70
void pack (const irept &irep, packedt &);
0 commit comments