Changeset 2177 for XIOS


Ignore:
Timestamp:
07/12/21 19:58:18 (3 years ago)
Author:
ymipsl
Message:

Correct problem in hash methods for vector.
Implement hash combine.
YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/utils.hpp

    r1474 r2177  
    181181      for(int i = 0; i < sizeVec; ++i) 
    182182      { 
    183         hash ^= i + 0x9e3779b9 + (hash << 6) + (hash >> 2); 
     183        hash ^= jenkins_hash(vec[i]) + 0x9e3779b9 + (hash << 6) + (hash >> 2); 
    184184      } 
    185185      return hash; 
    186186    } 
     187 
     188    static inline size_t hash_combine(size_t seed, const T& value) 
     189    { 
     190      seed ^= jenkins_hash(value) + 0x9e3779b9 + (seed << 6) + (seed >> 2); 
     191      return seed; 
     192    } 
     193 
    187194  }; 
    188195 
     
    200207      return HashAlgorithm<T>::boost_hash(vec); 
    201208    } 
    202  
     209     
     210    std::size_t hashCombine(size_t seed, const T& val) 
     211    { 
     212      return HashAlgorithm<T>::hash_combine(seed, val); 
     213    } 
    203214  private: 
    204215    size_t hash_value(const T& val, Int2Type<0>) 
Note: See TracChangeset for help on using the changeset viewer.