I was thinking pretty much along the same lines. The OP, however, seems to want it both compact and fast. Binary search will likely not satisfy the latter requirement. Couple links I googled up that might be of interest here:
In reply to Re^2: Bidirectional lookup algorithm? (Updated: further info.)
by oiskuu
in thread Bidirectional lookup algorithm? (Updated: further info.)
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |