Блог пользователя Taha1506

Автор Taha1506, история, 3 года назад, По-английски

Can anyone suggest a good string hashing template to use? I had a look at katcl's one and it was complicated also tourist didn't have any string hashing algorithm on his github. I tried to implement it myself but I was not very good with c++ syntax to be able to write it my self. So any suggestions?

  • Проголосовать: нравится
  • +9
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится +14 Проголосовать: не нравится

Does this work?

I haven't benchmarked it thoroughly, but it should be fairly fast and easy to use.

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks. It seems easy to work. But it is a bit strange in my openion using ull will make arithmetic a bit hard ? won't it like subracting a small number from a big one

    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Used the unsigned type because it's typically faster. There was a minor issue while subtracting hashes due to the use of the unsigned type which I've just fixed.

      If you use it as a template, you wouldn't usually need to add/subtract hashes. So it doesn't matter much what type you use.

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Template that supports only two hashes (which is typically enough though).