Created
          June 19, 2016 16:57 
        
      - 
      
- 
        Save daniel-abramov/501c46898522bd54bbdabefd572c00db to your computer and use it in GitHub Desktop. 
    FNV hash for strings
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | uint64_t fnvhash(const char* data, size_t size) { | |
| uint64_t hsh = 14695981039346656037L; | |
| for (size_t i = 0; i < size; ++i) { | |
| hsh = (hsh * 1099511628211L) ^ (uint64_t)(data[i]); | |
| } | |
| return hsh; | |
| } | |
| // Calculating the hash for QString | |
| template <> | |
| struct hash<QString> { | |
| size_t operator() (const QString& s) { | |
| return fnvhash(s.data(), s.size()); | |
| } | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment