c++ - Direction of for loop based on variable -


i have couple of biggish loops separate functions reduce code duplication.

the difference between them first line of loop.

one is:

for (int j = 50; j < average_diff; j++) { 

the other is:

for (int j = upper_limit; j > lower_limit; j--) { 

i have integer, tb indicates 1 i'd use (it has value of 1 or 2 respectively).

i'm wondering how might best accomplish this. use case macros?

don't wrap for, wrap contents in function:

for (int j = 50; j < average_diff; j++) {    process(j); }  (int j = upper_limit; j > lower_limit; j--) {    process(j); } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -