Skip to content

Instantly share code, notes, and snippets.

@navono
Created December 19, 2023 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navono/4ca0e38008dd7b6d1a5aa9e7a9564858 to your computer and use it in GitHub Desktop.
Save navono/4ca0e38008dd7b6d1a5aa9e7a9564858 to your computer and use it in GitHub Desktop.
hash string then can use it in switch statement
constexpr unsigned int hash(const char* s, int off = 0) {
return !s[off] ? 5381 : (hash(s, off + 1) * 33) ^ s[off];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment