Taha1506's blog

By Taha1506, history, 2 months ago, In English

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?

 
 
 
 
  • Vote: I like it
  • +9
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it +14 Vote: I do not like it

Does this work?

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

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

    • »
      »
      »
      2 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

      • »
        »
        »
        »
        2 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I see there is no need for subtractiong thanks!

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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