Fixed signed integer overflow. Closes #1
This commit is contained in:
@@ -521,13 +521,9 @@ struct Iterator {
|
|||||||
|
|
||||||
// Call Stepwise::step for each element of remaining until it returns true.
|
// Call Stepwise::step for each element of remaining until it returns true.
|
||||||
// Applies a permutation to `remaining` as a side effect.
|
// Applies a permutation to `remaining` as a side effect.
|
||||||
template <class Stepwise>
|
template <class Stepwise> void runInterleaved(std::span<Stepwise> remaining) {
|
||||||
void runInterleaved(std::span<Stepwise> remaining, int stepLimit = -1) {
|
|
||||||
while (remaining.size() > 0) {
|
while (remaining.size() > 0) {
|
||||||
for (int i = 0; i < int(remaining.size());) {
|
for (int i = 0; i < int(remaining.size());) {
|
||||||
if (stepLimit-- == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bool done = remaining[i].step();
|
bool done = remaining[i].step();
|
||||||
if (done) {
|
if (done) {
|
||||||
if (i != int(remaining.size()) - 1) {
|
if (i != int(remaining.size()) - 1) {
|
||||||
@@ -542,16 +538,9 @@ void runInterleaved(std::span<Stepwise> remaining, int stepLimit = -1) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Stepwise>
|
template <class Stepwise> void runSequential(std::span<Stepwise> remaining) {
|
||||||
void runSequential(std::span<Stepwise> remaining, int stepLimit = -1) {
|
|
||||||
for (auto &r : remaining) {
|
for (auto &r : remaining) {
|
||||||
if (stepLimit-- == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (!r.step()) {
|
while (!r.step()) {
|
||||||
if (stepLimit-- == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user