I have a code pattern which translates one integer to another. Just like this:
int t(int value) {
switch (value) {
case 1: return const_1;
ca
An array will have the fastest access time, by definition.
The switch statement compares values, then uses a jump table (which is an array of function pointers).
The hashmap computes a hash value from the data, then either searches a tree in memory or uses the hash value as an index into an array. Slow because of computing the hash value.
On most modern platforms, 64k, is not a big amount of data and can be statically allocated as a constant array.
One problem with the array technique is account for keys that you have not accounted for. One example is to use a unique sentinel value. When the value is returned, you know you have an unknown key.
I suggest using a static const
array of values.