Lookup Tables
- I don't find myself using lookup tables very often, but
that may be because of the type of programming I do, or
because I don't think of it is a separate mechanism.
- The basic idea is that you make a boolean array the size of each
possible item.
- If you have the item, you make the boolean element true, if not
you make it false.
- So, if I had some characters that I wanted to check, I'd
make a boolean array that was 256 for ASCII (that's all possible
characters including space, capitals, lower case, number,
punctuation etc.)
- I'd then fill in the values.
- If I had stored b,d and f I'd have
97 | 98 | 99 | 100 |
101 | 102 | 103 |
a | b | c | d |
e | f | g |
false | true | false | true |
false | true | false |
- The table would be just the boolean bit.
- The offsets would be the ascii codes (which I only got when I
whipped up a java program to test this).