Skip to content

Commit

Permalink
Add operator< to rolling_hash::Hash (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
hitonanode authored Jan 13, 2024
1 parent 41bbc3d commit 6399b65
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions string/rolling_hash_1d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ template <typename V> struct rolling_hash {
return length == r.length and val == r.val;
}

bool operator<(const Hash &x) const { // To use std::map
if (length != x.length) return length < x.length;
return val < x.val;
}

Hash operator*(const Hash &r) const {
return Hash(length + r.length, val * power.at(r.length) + r.val);
}
Expand Down

0 comments on commit 6399b65

Please sign in to comment.