Search Results
6/20/2025, 2:26:26 AM
currently rebuilding the wheel here, using a nested for loop to search a 3x3 area around a center tile. It looks like this:
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
If I need to break out of both the inner and the outer loop (and I don't want to use a goto), can I just rewrite it as:
for (int m = 0; m < 9; m++) {
int i = m % 3 - 1
int j = m / 3 - 1
and use break? I imagine it will perform slightly slower having to do the math, but the perfomance difference has got to be tiny
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
If I need to break out of both the inner and the outer loop (and I don't want to use a goto), can I just rewrite it as:
for (int m = 0; m < 9; m++) {
int i = m % 3 - 1
int j = m / 3 - 1
and use break? I imagine it will perform slightly slower having to do the math, but the perfomance difference has got to be tiny
Page 1