galapogos said:
Could you elaborate? I know the concept of a hashtable but I don't have
much experience with it and I don't see how it relates to the problem.
Are you saying each pattern will hash into the table and hopefully no
collisions will take place? Some kinda example would be great...thanks!
If you want to be able to do switch on these numbers then I guess
you have a finite manageable number of them and they are known
at compile time. Come up with some type of preprocessor which
converts your bit patterns to valid case labels, and make the
argument to the switch statement a call to a C function which
does the same hash.
This is basically Galapogos's proposal, although his suggested
'program P' would also try to analyze the set of bit patterns
you use to produce the most efficient outcome, and could be
used when the number of bit patterns exceeds the range
representable by an operand to switch. However if you have
that many of them a switch statement would be a bit absurd.