I have std :: map for some package processing programs.
I did not notice before profiling, but, unfortunately, this map view by itself consumes about 10% of the processor time (the so-called too much time).
Typically, the input contains no more than 10 keys. Therefore, I am trying to implement a cache key in front of a card.
The key value is a 13-bit integer. I know that there are only 8192 possible keys, and an array of 8192 elements can give a constant search for time, but I already feel ashamed and do not want to use such a naive approach :(
Now I'm just guessing some kind of hashing method that very quickly outputs a 4-bit code value for a 13-bit integer.
Any cool idea?
Thanks in advance.
UPDATE
Besides my shame, I do not have full control over the source code, and for this purpose it is almost forbidden to create a new array.
The project manager said (who launched the profiler), the linked list showed a slight increase in performance and recommended using std :: list instead of std :: map.
UPDATE
The meaning of the keys is random (without relation) and does not have a good distribution.
Example:
1) 0x100, 0x101, 0x10, 0x0, 0xffe
2) 0x400, 0x401, 0x402, 0x403, 0x404, 0x405, 0xff