AMFNV1a  201909
String localization library
AMCEFNV1a.h
Go to the documentation of this file.
1 
8 #ifndef AMCEFNV1a_H
9 #define AMCEFNV1a_H
10 
11 #include <cstdint>
12 
18 namespace AMCore {
19 
51  {
52  static const std::uint64_t basis64 = 0xcbf29ce484222325ULL;
53  static const std::uint64_t prime64 = 0x100000001b3ULL;
54  static const std::uint32_t basis32 = 0x811c9dc5UL;
55  static const std::uint32_t prime32 = 0x01000193UL;
56  public:
62  static constexpr std::uint64_t fnv1a64(const char* input)
63  {
64  std::uint64_t hash = basis64;
65  const char* str = input;
66  while(*str) {
67  hash = (hash ^ (std::uint64_t)(*str)) * prime64;
68  str++;
69  }
70  return hash;
71  }
77  static constexpr std::uint32_t fnv1a32(const char* input)
78  {
79  std::uint32_t hash = basis32;
80  const char* str = input;
81  while(*str) {
82  hash = (hash ^ (std::uint32_t)(*str)) * prime32;
83  str++;
84  }
85  return hash;
86  }
87  };
88 
89 }//namespace
90 
93 #endif //AMCEFNV1a_H
AMCore::AMCEFNV1aAlgorithm::fnv1a64
static constexpr std::uint64_t fnv1a64(const char *input)
64bit variant of FNV1a Algorithm
Definition: AMCEFNV1a.h:62
AMCore::AMCEFNV1aAlgorithm::fnv1a32
static constexpr std::uint32_t fnv1a32(const char *input)
32bit variant of FNV1a Algorithm
Definition: AMCEFNV1a.h:77
AMCore::AMCEFNV1aAlgorithm
Constant expression implementation of FNV1a Algorithm.
Definition: AMCEFNV1a.h:50