How to quick check the input parameter?
an input integer is limited by an array of data: [Maski, possible-value-i], (i from 0-n)
which means the input param is a legal parameter only there is at least one i makes开发者_如何学Go ,
param & Maski == possible-value-i,
Maski may equal to Maskj.
So far I have to check each Mask one by one for parameter legality. Is there a way to compress these Mask checks to get a smaller one? (Or not the exact same check but I can use as a quick check for performance improvement).
What you have here is a circuit minimization problem. Each condition you have is of the form
x_i1 = m_i1 & x_i2 = m_i2 & ...
These conditions are then combined with the or - operator. You can simplify your expression using the Quine-McCluskey algorithm.
精彩评论