Last active
March 9, 2022 01:35
-
-
Save jneem/4e3e80c0f1a227cbf440625ea6b38bb1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Guaranteed to return a value strictly bigger than x (as long as x is finite). | |
// If x is infinite, will drain the list and then return infinity. | |
double next(list<double> *const ys, double x) | |
{ | |
while (!s->empty()) | |
{ | |
double y = /* some computation depending on x and ys->front() */; | |
if (y > x) | |
return y; | |
s->pop_front(); | |
} | |
return infinity(); | |
} | |
void loop(list<double> const* ys) | |
{ | |
double x = -infinity(); | |
while (!s->empty()) { | |
x = next(ys, x); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment