Skip to content

Commit 3c61cf2

Browse files
Add a hash function for nodes
This is to be able to use containers such as unordered_set/unordered_map
1 parent 23f8cd4 commit 3c61cf2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/solvers/refinement/string_refinement_util.h

+17
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,23 @@ class string_dependenciest
263263
: kind(STRING), index(string_node.index)
264264
{
265265
}
266+
267+
bool operator==(const nodet &n) const
268+
{
269+
return n.kind == kind && n.index == index;
270+
}
271+
};
272+
273+
/// Hash function for nodes
274+
// NOLINTNEXTLINE(readability/identifiers)
275+
struct node_hash
276+
{
277+
size_t
278+
operator()(const string_dependenciest::nodet &node) const optional_noexcept
279+
{
280+
return 2 * node.index +
281+
(node.kind == string_dependenciest::nodet::STRING ? 0 : 1);
282+
}
266283
};
267284

268285
mutable std::vector<optionalt<exprt>> eval_string_cache;

0 commit comments

Comments
 (0)