I know that this has already been discussed, and there are several answers to it. See Performance of an array of functions on if and switch statements , however I would like to get some other ideas.
I have a function with a big switch
. This is a 26 case
and each with the left
or right
option. This function returns a pointer based on two given parameters ( plane
and direction
):
double* getPointer(int plane, int direction) { switch (plane) { case 0: if (direction == 0) return p_YZ_L; // Left else if (dir == 1) return p_YZ_R; //Right else { return 0; } break; ... case 25: ... } }
from
planes -> [0-25] direction -> [0,1]
I thought of a lot of features, but it can also be tedious, and I'm not sure if this is the best option. It is also not clear to me how to do this properly. Any ideas?
source share