Last active
April 29, 2017 11:36
-
-
Save deque-blog/7490d39df97802ba2d1d3d27416f38b3 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> | |
std::vector<std::pair<double, Value>> make_intervals( | |
std::vector<Weighted<Value>> const& weighted_values) | |
{ | |
std::vector<std::pair<double, Value>> intervals; | |
intervals.reserve(weighted_values.size()); | |
double summed_weights = 0.0; | |
for (auto const& weighted_value: weighted_values) | |
{ | |
summed_weights += weighted_value.m_weight; | |
intervals.emplace_back(summed_weights, weighted_value.m_value); | |
} | |
return intervals; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment