Euphoria
hash.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string_view>
4 
5 #include "base/ints.h"
6 
7 namespace eu::core
8 {
9  // implements fnv-1a: https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
10 
11  constexpr U64 hash64(const std::string_view str, U64 hash = 0xcbf29ce484222325)
12  {
13  return str.empty() ? hash : hash64(str.substr(1), (hash ^ str[0]) * 0x100000001b3);
14  }
15 }
constexpr U64 hash64(const std::string_view str, U64 hash=0xcbf29ce484222325)
Definition: hash.h:11
std::uint64_t U64
Definition: ints.h:12