Last active
April 29, 2017 11:37
-
-
Save deque-blog/7f58dabc6b09686e0354964a445ccbaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename Value> | |
Value search_containing_interval( | |
std::vector<std::pair<double, Value>> const& intervals, double weight) | |
{ | |
auto it = std::lower_bound( | |
intervals.begin(), intervals.end(), weight, | |
[](auto const& element, double weight) | |
{ | |
return element.first < weight; | |
}); | |
return it->second; //By construction, always exists | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment