I am doing some financial trading work. I have a set of stock symbols but they have very clear pattern:
it's composed of two characters AB
, AC
AD
and current month which is a four digit number: 1503
, 1504
, 1505
. Some examples are:
AB1504
AB1505
AC1504
AC1505
AD1504
AD1505
....
Since these strings are so well designed patterned, I want to map (hash) each of the string into a unique integer so that I can use the integer as the array index for fast accessing, since I have a lot of retrievals inside my system and std::unordered_map
or any other hash map are not fast enough. I have tests showing that general hash map are hundred-nanoseconds latency level while array indexing is always under 100 nanos.
my ideal case would be, for example, AB1504
maps to integer 1
, AB1505
maps to 2
...., then I can create an array inside to access the information related to these symbols much faster.
I'm trying to figure out some hash algorithms or other methods that can achieve my goal but couldn't find out.
Do you guys have any suggestions on this problem?