cprover
irep_hash_container.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: IREP Hash Container
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_UTIL_IREP_HASH_CONTAINER_H
13 #define CPROVER_UTIL_IREP_HASH_CONTAINER_H
14 
15 #include <cstdlib> // for size_t
16 #include <vector>
17 
18 #include "numbering.h"
19 
20 class irept;
21 
23 {
24 public:
25  size_t number(const irept &irep);
26 
27  explicit irep_hash_container_baset(bool _full):full(_full)
28  {
29  }
30 
31  void clear()
32  {
33  numbering.clear();
34  }
35 
36 protected:
37  // replacing the following two hash-tables by
38  // std::maps doesn't make much difference in performance
39 
40  // this is the first level: address of the content
41 
43  {
44  size_t operator()(const void *p) const
45  {
46  return (size_t)p;
47  }
48  };
49 
50  typedef std::unordered_map<const void *, size_t, pointer_hasht>
53 
54  // this is the second level: content
55 
56  typedef std::vector<size_t> packedt;
57 
58  struct vector_hasht
59  {
60  size_t operator()(const packedt &p) const;
61  };
62 
64  numberingt numbering;
65 
66  void pack(const irept &irep, packedt &);
67 
68  bool full;
69 };
70 
71 // excludes comments
74 {
75 public:
77  {
78  }
79 };
80 
81 // includes comments
84 {
85 public:
87  {
88  }
89 };
90 
91 #endif // CPROVER_UTIL_IREP_HASH_CONTAINER_H
void clear()
Definition: numbering.h:59
std::vector< size_t > packedt
std::unordered_map< const void *, size_t, pointer_hasht > ptr_hasht
Base class for tree-like data structures with sharing.
Definition: irep.h:87
void pack(const irept &irep, packedt &)
size_t number(const irept &irep)
hash_numbering< packedt, vector_hasht > numberingt