Like the title says, I'm trying to find elements of M that exist in the large constant array N. Most of the time, no element of M will exist in N, so the vast majority of searches done on M are a waste of time.
I'm looking for some way to create an index to check before doing a full-scale search of M. A project similar to mine creates a bit array from the first few bytes of every element of M, and from what I understand, leverages bit level parallelism to search it quickly. I don't understand entirely how this works.
So what tricks can I use to cut down the chance of searching M unnecessarily?
This is a mostly language independent question, but just to be as complete as possible, I'm using C++.