in reply to Efficient selection mechanism?
This is a brute force approach:
I would pack the four small integers as bits in a 32-bit integer instead of using an array. Then the problem reduces to scanning that array and checking each bit against the bitmask.
If you sort the 32-bit integers, you get a quick way of eliminating half of the search space by looking at the highest bit.
|
|---|