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
I think it is not obvious which is going to be faster. You might need to profile both approaches.
The hash map should have complexity of O(1).
The switch (with non-contiguous keys like yours) may be optimized into a binary search (at least with GCC), which has complexity of O(log n).
On the other hand, any operation done on a hash map will be much more expensive than an operation done in a switch.