I have an array of a few million numbers.
double* const data = new double (3600000);
I need to iterate through the array and find the range (th
std::multiset range; double currentmax = 0.0; for (int i = 0; i < 3600000; ++i) { if (i >= 1000) range.erase(range.find(data[i-1000])); range.insert(data[i]); if (i >= 999) currentmax = max(currentmax, *range.rbegin()); }
Note untested code.
Edit: fixed off-by-one error.