@@ -92,4 +92,91 @@ class irep_full_hash_containert:
92
92
}
93
93
};
94
94
95
+ template <typename Key, typename T>
96
+ class irep_hash_mapt
97
+ {
98
+ protected:
99
+ using mapt = std::map<std::size_t , T>;
100
+
101
+ public:
102
+ using key_type = Key;
103
+ using mapped_type = T;
104
+ using value_type = std::pair<const Key, T>;
105
+ using const_iterator = typename mapt::const_iterator;
106
+ using iterator = typename mapt::iterator;
107
+
108
+ const_iterator find (const Key &key) const
109
+ {
110
+ return map.find (hash_container.number (key));
111
+ }
112
+
113
+ iterator find (const Key &key)
114
+ {
115
+ return map.find (hash_container.number (key));
116
+ }
117
+
118
+ const_iterator begin () const
119
+ {
120
+ return map.begin ();
121
+ }
122
+
123
+ iterator begin ()
124
+ {
125
+ return map.begin ();
126
+ }
127
+
128
+ const_iterator end () const
129
+ {
130
+ return map.end ();
131
+ }
132
+
133
+ iterator end ()
134
+ {
135
+ return map.end ();
136
+ }
137
+
138
+ void clear ()
139
+ {
140
+ hash_container.clear ();
141
+ map.clear ();
142
+ }
143
+
144
+ std::size_t size () const
145
+ {
146
+ return map.size ();
147
+ }
148
+
149
+ bool empty () const
150
+ {
151
+ return map.empty ();
152
+ }
153
+
154
+ T &operator [](const Key &key)
155
+ {
156
+ const std::size_t i = hash_container.number (key);
157
+ return map[i];
158
+ }
159
+
160
+ std::pair<iterator, bool > insert (const value_type &value)
161
+ {
162
+ const std::size_t i = hash_container.number (value.first );
163
+ return map.emplace (i, value.second );
164
+ }
165
+
166
+ void erase (iterator it)
167
+ {
168
+ map.erase (it);
169
+ }
170
+
171
+ void swap (irep_hash_mapt<Key, T> &other)
172
+ {
173
+ std::swap (hash_container, other.hash_container );
174
+ std::swap (map, other.map );
175
+ }
176
+
177
+ protected:
178
+ mutable irep_hash_containert hash_container;
179
+ mapt map;
180
+ };
181
+
95
182
#endif // CPROVER_UTIL_IREP_HASH_CONTAINER_H
0 commit comments