CommonLibSSE (powerof3)
GFixedSizeHash.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace RE
4 {
5  template <class T>
7  {
8  public:
9  // http::/www.cs.yorku.ca/~oz/hash.html
10  static inline UPInt SDBM_Hash(const void* a_dataIn, UPInt a_size, UPInt a_seed = 5381)
11  {
12  const std::uint8_t* data = static_cast<const std::uint8_t*>(a_dataIn);
13  UPInt hash = a_seed;
14  while (a_size > 0) {
15  hash = (hash << 16) + (hash << 6) - hash + static_cast<const UPInt>(data[a_size--]);
16  }
17  return hash;
18  }
19 
20  UPInt operator()(const T& a_data) const
21  {
22  return SDBM_Hash(&a_data, sizeof(T));
23  }
24  };
25  static_assert(sizeof(GFixedSizeHash<void*>) == 0x1);
26 }
Definition: GFixedSizeHash.h:7
static UPInt SDBM_Hash(const void *a_dataIn, UPInt a_size, UPInt a_seed=5381)
Definition: GFixedSizeHash.h:10
UPInt operator()(const T &a_data) const
Definition: GFixedSizeHash.h:20
Definition: AbsorbEffect.h:6
std::size_t UPInt
Definition: SFTypes.h:5