if statement - What is the most efficient logic to check for all possible combinations of three flags? -



if statement - What is the most efficient logic to check for all possible combinations of three flags? -

i have 3 flags may true or false. need display icon each possible combination of flags. since there 3 flags means, in combination, there 8 possible states. (shown below, bold represents true.)

a b c

a b c

a b c

a b c

a b c

a b c

a b c

a b c

is there advantageous command flow utilize in checking flags minimize unnecessary checking? (would vary flags likely on or off?)

edit:

for example, when looking @ flags , b, command flow -

if(a & b) { // display icon a+b } else if (a) { // display icon } else if (b) { // display icon b }

i set 8 bit variable, allowing bits 2,1,0 store flag states.

then

switch(variablename) { case 0: break; .. .. case 7: break; }

if-statement switch-statement logic control-flow

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -