From 3c0ddf3021bad052cc61169245521232183f9e5a Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 23 Aug 2024 21:40:22 +0100 Subject: [PATCH] Add given code --- src/include/interval-map/interval-map.hh | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/include/interval-map/interval-map.hh b/src/include/interval-map/interval-map.hh index 6f70f09..ce1d9dd 100644 --- a/src/include/interval-map/interval-map.hh +++ b/src/include/interval-map/interval-map.hh @@ -1 +1,27 @@ #pragma once + +#include + +namespace amby { + +template class interval_map { +public: + interval_map(V const& init) : init_(init) {} + + void assign(K const& begin, K const& end, V const& val) { + // TODO: implement + } + + V const& operator[](K const& key) const { + auto it = underlying_.upper_bound(key); + if (it == underlying_.begin()) + return init_; + return std::prev(it)->second; + } + +private: + V init_; + std::map underlying_{}; +}; + +} // namespace amby