TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::Hash Namespace Reference

Functions

constexpr uint64_t CalculateConst (std::string_view str, uint64_t hash=Basis)
 FNV-1a hash of str, usable at compile time; hash continues an earlier hash.
uint64_t Calculate (std::string_view str)
 FNV-1a hash of str; same result as CalculateConst.
uint64_t CalculateBytes (const void *data, size_t len)
 FNV-1a hash of len bytes at data.
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<std::decay_t<T>> && !std::is_pointer_v<std::decay_t<T>> && !std::is_same_v<std::decay_t<T>, std::string_view>>>
uint64_t Calculate (const T &value)
 FNV-1a hash of a trivially-copyable value's bytes, padding included.
constexpr uint64_t Combine (uint64_t a, uint64_t b)
 Order-dependent combine; repeated values don't cancel out.
template<typename... Args>
constexpr uint64_t Combine (const Args &... args)
 Combines the Calculate hashes of args, in order.

Variables

constexpr uint64_t Basis = 14695981039346656037ULL
 FNV-1a 64-bit offset basis (Prime is the FNV-1a prime).
constexpr uint64_t Prime = 1099511628211ULL

Function Documentation

◆ CalculateConst()

uint64_t tachyon::Hash::CalculateConst ( std::string_view str,
uint64_t hash = Basis )
constexpr

FNV-1a hash of str, usable at compile time; hash continues an earlier hash.

◆ Calculate() [1/2]

uint64_t tachyon::Hash::Calculate ( std::string_view str)
inline

FNV-1a hash of str; same result as CalculateConst.

◆ CalculateBytes()

uint64_t tachyon::Hash::CalculateBytes ( const void * data,
size_t len )
inline

FNV-1a hash of len bytes at data.

◆ Calculate() [2/2]

template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<std::decay_t<T>> && !std::is_pointer_v<std::decay_t<T>> && !std::is_same_v<std::decay_t<T>, std::string_view>>>
uint64_t tachyon::Hash::Calculate ( const T & value)
inline

FNV-1a hash of a trivially-copyable value's bytes, padding included.

Pointers are rejected: hashing one hashes the address, not the object.

◆ Combine() [1/2]

uint64_t tachyon::Hash::Combine ( uint64_t a,
uint64_t b )
inlineconstexpr

Order-dependent combine; repeated values don't cancel out.

◆ Combine() [2/2]

template<typename... Args>
uint64_t tachyon::Hash::Combine ( const Args &... args)
inlineconstexpr

Combines the Calculate hashes of args, in order.

Variable Documentation

◆ Basis

uint64_t tachyon::Hash::Basis = 14695981039346656037ULL
constexpr

FNV-1a 64-bit offset basis (Prime is the FNV-1a prime).

◆ Prime

uint64_t tachyon::Hash::Prime = 1099511628211ULL
constexpr