Skip to content

Commit 6df6405

Browse files
Add a hash function for nodes
This is to be able to use containers such as unordered_set/unordered_map
1 parent ee28415 commit 6df6405

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/solvers/refinement/string_refinement_util.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,22 @@ class string_dependenciest
251251
: kind(STRING), index(string_node.index)
252252
{
253253
}
254+
255+
bool operator==(const nodet &n) const
256+
{
257+
return n.kind == kind && n.index == index;
258+
}
259+
};
260+
261+
/// Hash function for nodes
262+
// NOLINTNEXTLINE(readability/identifiers)
263+
struct node_hash
264+
{
265+
size_t operator()(const string_dependenciest::nodet &node) const noexcept
266+
{
267+
return 2 * node.index +
268+
(node.kind == string_dependenciest::nodet::STRING ? 0 : 1);
269+
}
254270
};
255271

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

0 commit comments

Comments
 (0)