Perfect hash function generator for functions

后端 未结 1 1452
长情又很酷
长情又很酷 2021-01-18 12:52

I have a set of C++ functions. I want to map this functions in an hash table, something like: unordered_map , SomethingElse>

1条回答
  •  别那么骄傲
    2021-01-18 12:55

    Ok, maybe not what you want to hear but consider this: since you talk about a few functions, less than 50, the hash lookup should be negligible, even with collisions. Have you actually profiled and saw that the lookup is critical?

    So my advise is to focus your energy on something else, most likely a perfect hash function would not bring any kind of improved performance in your case.

    I am going to go one step further and say that I think that for less than 50 elements a flat map (good ol' vector) would have similar performance (or maybe even better due to cache locality). But again, measurements are required.

    0 讨论(0)
提交回复
热议问题