From f1ad308d712457012760c8df4c9bc4b62a5473d8 Mon Sep 17 00:00:00 2001 From: hitonanode <32937551+hitonanode@users.noreply.github.com> Date: Sat, 13 Jan 2024 20:17:59 +0900 Subject: [PATCH] Add operator< to rolling_hash::Hash --- string/rolling_hash_1d.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/string/rolling_hash_1d.hpp b/string/rolling_hash_1d.hpp index ff2492ca..b2f2127d 100644 --- a/string/rolling_hash_1d.hpp +++ b/string/rolling_hash_1d.hpp @@ -97,6 +97,11 @@ template 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); }