I have data consists of keys mapped to values, like this:
---------------------
Key | Value
---------------------
(0, 0, 0, 0) | a
(0, 0, 0, 1) | b
(0,
Code each relation as a line of text then use a regular expression where '.' can match any single character at that position in the key.
This would remove any restriction on where the don't cares are.
Here's some Python:
>>> import re
>>>
>>> map = '''
... 0000 a
... 0001 b
... 0101 c
... 0110 d
... '''
>>>
>>> def search(query='0001'):
... matches = re.findall(query + r' .', map)
... return [match.split()[-1] for match in matches]
...
>>> search('0001')
['b']
>>> search('0...')
['a', 'b', 'c', 'd']
>>> search('01..')
['c', 'd']
>>>