Q:

Convert float number from nonuniform ranges

So I have this, relatively easy, problem and wondering if the solution for it already exists. 
I have to convert a value from one range to another.  If there was just one range, like this:
 {-30.0, 30.0} -> {25.0, 50.0}

that would have been easy. 
But I have a set of ranges:
 {-30.0, -20.0} -> {25.0, 30.0}
 {-20.0,   0.0} -> {30.0, 40.0}
 {  0.0,  30.0} -> {40.0, 50.0}

One solution is to do a linear search on each access. 
Another solution is to make the ranges to have equivalent length so that the input value could be directly mapped. 
Does anyone know a better than linear search solution?  Or if a container that performs this kind of conversion already exist? 
Thanks so much. 

A:

This is an elaboration on the solution presented by @user1034749.  It uses an std::set with a class that contains two pairs of values. 
template<class SRC, class DST>
class Range {
 public:
  std::pair<SRC, SRC> src_range;
  std::pair<DST, DST> dst_range;

  bool operator<(const Range& rhs) const {
    return (src_range.first < rhs.src_range.first) && (src_range.second < rhs.src_range.second);
  }

  Range(SRC src_first, SRC src_second,
        DST dst_first, DST dst_second)
  : src_range(src_first, src_second),
    dst_range(dst_first, dst_second) {}

  Range()
  : src_range(0, 0),
    dst_range(0, 0) {}

  Range(SRC value)
  : src_range(value, value),
    dst_range(value, value) {}
};

bool mapping_test() {
  // Mapping
  std::set<Range<double,double>>
          z = {{-30.0, -20.0, -10.0, -5.0},
               {-20.0, 0, -5.0, 5.0},
               {0, 10.0, 5.0, 8.0}};

  // Find range that contains this value
  Range<double,double> f{8.0};

  auto d = z.find(f);
  if(d ! = z.end()) {
    std::cout << "Found {" << (*d).dst_range.first
                           << ","
                           << (*d).dst_range.second
                           << "}\n";
  }

  return true;
}

In this case the range for the value in question could be found including source range as well as destination.  Lookup in the std::set container is log(n) complexity.