Dukales

Hash for difference of pointers with good avalanche effect

Aug 10th, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <x86intrin.h>
  2.  
  3. struct phash
  4. {
  5.  
  6.     std::size_t
  7.     operator () (std::intptr_t const _offset) const noexcept
  8.     {
  9. #if defined(__x86_64__)
  10.         return _mm_crc32_u64(0, static_cast< std::uintptr_t >(_offset));
  11. #elif defined(__i386__)
  12.         return _mm_crc32_u32(0, static_cast< std::uintptr_t >(_offset));
  13. #endif
  14.     }
  15.  
  16. };
Advertisement
Add Comment
Please, Sign In to add comment