header_utils
Loading...
Searching...
No Matches
Hashes

Hashing functions. More...

Functions

template<bytelike_range RANGE>
constexpr uint32_t ghassanpl::crc32 (RANGE &&bytes)
 Calculates a CRC32 for a range of bytelikes.
 
template<bytelike... BYTES>
constexpr uint32_t ghassanpl::crc32 (BYTES... bytes)
 Calculates a CRC32 for a variadic number of bytelikes.
 
constexpr auto ghassanpl::crc32 (const source_location &k)
 Calculates a CRC32 of a source_location (constexpr, so can be used at compile time)
 
template<bytelike_range RANGE>
constexpr uint64_t ghassanpl::crc64 (RANGE &&bytes)
 Calculates a CRC4 for a range of bytelikes.
 
template<bytelike... BYTES>
constexpr uint64_t ghassanpl::crc64 (BYTES... bytes)
 Calculates a CRC4 for a variadic number of bytelikes.
 
constexpr auto ghassanpl::crc64 (const source_location &k)
 Calculates a CRC64 of a source_location (constexpr, so can be used at compile time)
 
template<bytelike_range RANGE>
constexpr uint64_t ghassanpl::fnv64 (RANGE &&bytes)
 TODO: Add support for non-64bit hashes to all the functions below, especially since std::hash operates on size_t.
 
template<bytelike... BYTES>
constexpr uint64_t ghassanpl::fnv64 (BYTES... bytes)
 Calculates a FNV Hash for a variadic number of bytes.
 
template<typename T , typename HASHER = std::hash<std::remove_cvref_t<T>>>
constexpr void ghassanpl::hash64_combine_to (uint64_t &seed, T &&v, HASHER &&hasher=HASHER{})
 TODO: ce_hash64(array/span) TODO: ce_hash64(thread::id) ? TODO: ce_hash64(optional/variant) ?
 
template<typename It , typename HASHER = std::hash<std::iter_value_t<It>>>
constexpr void ghassanpl::hash64_range (uint64_t &seed, It first, It last, HASHER const &hasher={})
 Combines an existing hash value (seed) with the hash of a range of values.
 
template<typename It , typename HASHER = std::hash<std::iter_value_t<It>>>
constexpr uint64_t ghassanpl::hash64_range (It first, It last, HASHER &&hasher={})
 Hashes a range of values.
 
template<std::ranges::range T, typename HASHER = std::hash<std::ranges::range_value_t<T>>>
constexpr uint64_t ghassanpl::hash64_range (T range, HASHER &&hasher={})
 Hashes a range of values.
 

Detailed Description

Hashing functions.

Function Documentation

◆ crc32() [1/3]

template<bytelike... BYTES>
constexpr uint32_t ghassanpl::crc32 ( BYTES...  bytes)
constexpr

Calculates a CRC32 for a variadic number of bytelikes.

constexpr!

Definition at line 80 of file hashes.h.

◆ crc32() [2/3]

constexpr auto ghassanpl::crc32 ( const source_location &  k)
constexpr

Calculates a CRC32 of a source_location (constexpr, so can be used at compile time)

Definition at line 89 of file hashes.h.

◆ crc32() [3/3]

template<bytelike_range RANGE>
constexpr uint32_t ghassanpl::crc32 ( RANGE &&  bytes)
constexpr

Calculates a CRC32 for a range of bytelikes.

constexpr!

Definition at line 67 of file hashes.h.

◆ crc64() [1/3]

template<bytelike... BYTES>
constexpr uint64_t ghassanpl::crc64 ( BYTES...  bytes)
constexpr

Calculates a CRC4 for a variadic number of bytelikes.

Definition at line 143 of file hashes.h.

◆ crc64() [2/3]

constexpr auto ghassanpl::crc64 ( const source_location &  k)
constexpr

Calculates a CRC64 of a source_location (constexpr, so can be used at compile time)

Definition at line 152 of file hashes.h.

◆ crc64() [3/3]

template<bytelike_range RANGE>
constexpr uint64_t ghassanpl::crc64 ( RANGE &&  bytes)
constexpr

Calculates a CRC4 for a range of bytelikes.

Definition at line 132 of file hashes.h.

◆ fnv64() [1/2]

template<bytelike... BYTES>
constexpr uint64_t ghassanpl::fnv64 ( BYTES...  bytes)
constexpr

Calculates a FNV Hash for a variadic number of bytes.

Definition at line 179 of file hashes.h.

◆ fnv64() [2/2]

template<bytelike_range RANGE>
constexpr uint64_t ghassanpl::fnv64 ( RANGE &&  bytes)
constexpr

TODO: Add support for non-64bit hashes to all the functions below, especially since std::hash operates on size_t.

Calculates a FNV Hash for a range of bytes

Definition at line 168 of file hashes.h.

◆ hash64_combine_to()

template<typename T , typename HASHER = std::hash<std::remove_cvref_t<T>>>
constexpr void ghassanpl::hash64_combine_to ( uint64_t seed,
T &&  v,
HASHER &&  hasher = HASHER{} 
)
constexpr

TODO: ce_hash64(array/span) TODO: ce_hash64(thread::id) ? TODO: ce_hash64(optional/variant) ?

Combines an existing hash value (seed) with the hash of value v

Definition at line 308 of file hashes.h.

◆ hash64_range() [1/3]

template<typename It , typename HASHER = std::hash<std::iter_value_t<It>>>
constexpr uint64_t ghassanpl::hash64_range ( It  first,
It  last,
HASHER &&  hasher = {} 
)
constexpr

Hashes a range of values.

Definition at line 343 of file hashes.h.

◆ hash64_range() [2/3]

template<std::ranges::range T, typename HASHER = std::hash<std::ranges::range_value_t<T>>>
constexpr uint64_t ghassanpl::hash64_range ( range,
HASHER &&  hasher = {} 
)
constexpr

Hashes a range of values.

Definition at line 354 of file hashes.h.

◆ hash64_range() [3/3]

template<typename It , typename HASHER = std::hash<std::iter_value_t<It>>>
constexpr void ghassanpl::hash64_range ( uint64_t seed,
It  first,
It  last,
HASHER const hasher = {} 
)
constexpr

Combines an existing hash value (seed) with the hash of a range of values.

Definition at line 333 of file hashes.h.