Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dear experts, I am trying to solve this, put solution comes up as incorrect all the time. Please help here. #include template class interval_map {

Dear experts, I am trying to solve this, put solution comes up as incorrect all the time. Please help here.

#include  template class interval_map { friend void IntervalMapTest(); V m_valBegin; std::map m_map; public: // constructor associates whole range of K with val interval_map(V const& val) : m_valBegin(val) {} // Assign value val to interval [keyBegin, keyEnd). // Overwrite previous values in this interval. // Conforming to the C++ Standard Library conventions, the interval // includes keyBegin, but excludes keyEnd. // If !( keyBegin < keyEnd ), this designates an empty interval, // and assign must do nothing. void assign( K const& keyBegin, K const& keyEnd, V const& val ) {

// INSERT YOUR SOLUTION

 } // look-up of the value associated with key V const& operator[]( K const& key ) const { auto it=m_map.upper_bound(key); if(it==m_map.begin()) { return m_valBegin; } else { return (--it)->second; } } }; // Many solutions we receive are incorrect. Consider using a randomized test // to discover the cases that your implementation does not handle correctly. // We recommend to implement a test function that tests the functionality of // the interval_map, for example using a map of int intervals to char.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started