From 47543c9101923619a2cb7ad77fc8830a11c262e2 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Mon, 10 Apr 2023 00:28:42 +0200 Subject: [PATCH] intervalmap: use updated upper_bound when checking removal of next node --- include/intervalmap.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/intervalmap.hpp b/include/intervalmap.hpp index 6f7222b..7b20055 100644 --- a/include/intervalmap.hpp +++ b/include/intervalmap.hpp @@ -38,8 +38,9 @@ public: if(end_next_entry->first != end) treemap[end] = end_prev_entry->second; + auto e = treemap.upper_bound(end); // A little optimization: delete next key if it is of the same value of the end key - //if(end_next_entry->second == treemap[end]) treemap.erase(end_next_entry); + if(e != treemap.end() && e->second == treemap[end]) treemap.erase(end_next_entry); } // insert the start key. Replaces whatever value is already there. Do not place if the element before is of the same value