From 9d9091630712bb360d788dbb5449c002bb1e7025 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 23 Aug 2024 23:49:52 +0100 Subject: [PATCH] Add implementation --- src/include/interval-map/interval-map.hh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/include/interval-map/interval-map.hh b/src/include/interval-map/interval-map.hh index 4dc2335..1352b79 100644 --- a/src/include/interval-map/interval-map.hh +++ b/src/include/interval-map/interval-map.hh @@ -14,7 +14,16 @@ public: void assign(K const& begin, K const& end, V const& val) { if (!(begin < end)) return; - // TODO: implement + + auto const end_val = (*this)[end]; + underlying_.erase(underlying_.lower_bound(begin), + underlying_.upper_bound(end)); + if (!((*this)[begin] == val)) { + underlying_.insert({begin, val}); + } + if (!((*this)[end] == end_val)) { + underlying_.insert({end, end_val}); + } } V const& operator[](K const& key) const {