开发者

How to quick check the input parameter?

开发者 https://www.devze.com 2023-01-04 12:56 出处:网络
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 ,

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消