Created
March 1, 2012 01:48
-
-
Save rorydriscoll/1946538 to your computer and use it in GitHub Desktop.
String hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<unsigned int N, unsigned int I> | |
struct FnvHash | |
{ | |
__forceinline static uint32 Hash(const char (&text)[N]) | |
{ | |
return (FnvHash<N, I - 1>::Hash(text) ^ text[I - 1]) * 16777619u; | |
} | |
}; | |
template<unsigned int N> | |
struct FnvHash<N, 1> | |
{ | |
__forceinline static uint32 Hash(const char (&text)[N]) | |
{ | |
return (2166136261u ^ text[0]) * 16777619u; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment