Skip to content

Commit cd7c470

Browse files
Add a hash function for nodes
This is to be able to use containers such as unordered_set/unordered_map
1 parent 209a971 commit cd7c470

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/solvers/refinement/string_refinement_util.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,23 @@ 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
266+
operator()(const string_dependenciest::nodet &node) const optional_noexcept
267+
{
268+
return 2 * node.index +
269+
(node.kind == string_dependenciest::nodet::STRING ? 0 : 1);
270+
}
254271
};
255272

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

0 commit comments

Comments
 (0)