Skip to content

Commit 6399b65

Browse files
authored
Add operator< to rolling_hash::Hash (#324)
1 parent 41bbc3d commit 6399b65

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

string/rolling_hash_1d.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ template <typename V> struct rolling_hash {
9797
return length == r.length and val == r.val;
9898
}
9999

100+
bool operator<(const Hash &x) const { // To use std::map
101+
if (length != x.length) return length < x.length;
102+
return val < x.val;
103+
}
104+
100105
Hash operator*(const Hash &r) const {
101106
return Hash(length + r.length, val * power.at(r.length) + r.val);
102107
}

0 commit comments

Comments
 (0)