I was wondering... if I had many different functions that I wanted to call based on what the value of a variable would be, and the limits of that value where integral [0, N) , would the second method be much faster than the first?:
Code:
void proc1();
void proc2();
...
void procN();
1st:
Code:
switch (value)
{
case 0:
proc1();
break;
case 1:
proc2();
break;
...
case N-1:
procN();
break;
}
2nd:
Code:
typedef void (*procedure)();
procedure procArray[N] = { proc1, proc2, ... , procN };
...
procArray[value]();
In the case of indexing though, what "guessing" rules would apply, if any?