Click here to Skip to main content
15,887,683 members
Home / Discussions / Algorithms
   

Algorithms

 
Questionoptimizing the set of possible boolean outcomes of evaluating multiple conditions ? [modified] Pin
BillWoodruff16-Aug-11 19:02
professionalBillWoodruff16-Aug-11 19:02 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
David198716-Aug-11 20:00
David198716-Aug-11 20:00 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
BillWoodruff17-Aug-11 14:50
professionalBillWoodruff17-Aug-11 14:50 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
BillWoodruff17-Aug-11 21:46
professionalBillWoodruff17-Aug-11 21:46 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
David198717-Aug-11 21:52
David198717-Aug-11 21:52 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
BillWoodruff17-Aug-11 22:10
professionalBillWoodruff17-Aug-11 22:10 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
David198717-Aug-11 22:19
David198717-Aug-11 22:19 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? [modified] Pin
BillWoodruff24-Aug-11 20:55
professionalBillWoodruff24-Aug-11 20:55 
Hi David,

... edit #1 ...

An hour of reading on the web about what happens when switch statements get turned into IL turned out to be fascinating: in some cases if-then-else statements are generated ... in other cases jump-tables of the form you might expect when a continuous series of values are used as selector ... in other cases generic dictionaries may be generated and used as a look-up based solution, and even hashtables !

... end edit #1 ...

I took a look at the IL code generated by a switch statement with an integer selector, and I see code like this:
VB
IL_003e: switch (IL_00c4, IL_00d8, IL_00ec, IL_0100, IL_0114, IL_0128, IL_0309, IL_013c, IL_0150, IL_0165, IL_017a, IL_018f, IL_01a4, IL_01b9, IL_01ce, IL_01e3, IL_01f8, IL_020d, IL_0222, IL_0237, IL_024c, IL_0261, IL_0276, IL_0309, IL_028b, IL_029d, IL_02af, IL_02c1, IL_02d3, IL_02e5, IL_02f7)

IL_00bf: br IL_0309

IL_00c4: ldloc.1
IL_00c5: ldloc.1
IL_00c6: ldc.i4.1
IL_00c7: ldc.i4.1
IL_00c8: ldstr "!DCBAE"
IL_00cd: callvirt instance class Test5Parameters/BigSwitchBoolIntString Test5Parameters/BigSwitchBoolIntString::SetValue(class Test5Parameters/BigSwitchBoolIntString,  bool,  int32,  string)
IL_00d2: stloc.2
IL_00d3: br IL_0314
...
all the other cases
...

Seems reasonable to assume the IL instruction 'switch' is turned into a jump-table by the JIT-compiler, but are you certain of this ? It's beyond my abilities to view/grok what's produced by JIT.

thanks, Bill
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
modified on Thursday, August 25, 2011 9:27 AM

AnswerRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
Luc Pattyn17-Aug-11 15:59
sitebuilderLuc Pattyn17-Aug-11 15:59 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
BillWoodruff17-Aug-11 19:20
professionalBillWoodruff17-Aug-11 19:20 
Answerlink to usable c# sample of output of logic-matrix auto-generator for your review and comments Pin
BillWoodruff18-Aug-11 15:27
professionalBillWoodruff18-Aug-11 15:27 
AnswerRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? [modified] Pin
RobCroll19-Aug-11 5:02
RobCroll19-Aug-11 5:02 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
David198719-Aug-11 5:32
David198719-Aug-11 5:32 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
RobCroll19-Aug-11 5:46
RobCroll19-Aug-11 5:46 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
David198719-Aug-11 6:04
David198719-Aug-11 6:04 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? [modified] Pin
BillWoodruff19-Aug-11 6:51
professionalBillWoodruff19-Aug-11 6:51 
AnswerRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
GParkings3-Sep-11 5:57
GParkings3-Sep-11 5:57 
Questionconnection routing algorithm for connecting rectangles with lines ? Pin
BillWoodruff2-Aug-11 23:47
professionalBillWoodruff2-Aug-11 23:47 
GeneralRe: connection routing algorithm for connecting rectangles with lines ? Pin
David19875-Aug-11 1:21
David19875-Aug-11 1:21 
GeneralRe: connection routing algorithm for connecting rectangles with lines ? Pin
BillWoodruff5-Aug-11 2:10
professionalBillWoodruff5-Aug-11 2:10 
GeneralRe: connection routing algorithm for connecting rectangles with lines ? Pin
David19875-Aug-11 2:40
David19875-Aug-11 2:40 
GeneralRe: connection routing algorithm for connecting rectangles with lines ? Pin
BillWoodruff5-Aug-11 7:29
professionalBillWoodruff5-Aug-11 7:29 
AnswerRe: connection routing algorithm for connecting rectangles with lines ? Pin
cjb1106-Aug-11 9:35
cjb1106-Aug-11 9:35 
GeneralRe: connection routing algorithm for connecting rectangles with lines ? Pin
BillWoodruff7-Aug-11 13:02
professionalBillWoodruff7-Aug-11 13:02 
AnswerRe: connection routing algorithm for connecting rectangles with lines ? Pin
Member 41945937-Aug-11 10:48
Member 41945937-Aug-11 10:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.