|
solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
|
Collection of fast, non-cryptographic hash functions for general-purpose hashing. More...
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <xxhash.h>Go to the source code of this file.
Functions | |
| uint32_t | solidc_djb2_hash (const void *key) |
| DJB2 hash function for null-terminated strings. | |
| uint32_t | solidc_djb2a_hash (const void *key) |
| DJB2A hash function (XOR variant) for null-terminated strings. | |
| uint32_t | solidc_sdbm_hash (const void *key) |
| SDBM hash function for null-terminated strings. | |
| uint32_t | solidc_fnv1a_hash (const void *key) |
| FNV-1a 32-bit hash function for null-terminated strings. | |
| uint64_t | solidc_fnv1a_hash64 (const void *key) |
| FNV-1a 64-bit hash function for null-terminated strings. | |
| uint32_t | solidc_elf_hash (const void *key) |
| ELF hash function for null-terminated strings. | |
| uint32_t | solidc_crc32_hash (const void *key, size_t len) |
| CRC32 hash function for arbitrary binary data. | |
| uint32_t | solidc_murmur_hash (const char *key, uint32_t len, uint32_t seed) |
| MurmurHash3 32-bit hash function. | |
Collection of fast, non-cryptographic hash functions for general-purpose hashing.
This library provides several well-known hash functions suitable for hash tables, checksums, and other non-cryptographic applications. For cryptographic hashing, use dedicated cryptographic libraries instead.
Available hash functions:
Definition in file hash.h.
| uint32_t solidc_crc32_hash | ( | const void * | key, |
| size_t | len | ||
| ) |
CRC32 hash function for arbitrary binary data.
Cyclic Redundancy Check using standard CRC32 polynomial. Useful for checksums and data integrity verification.
| key | Pointer to data buffer |
| len | Length of data in bytes |
CRC32 hash function implementation. Standard CRC32 with polynomial 0xEDB88320.
Definition at line 110 of file hash.c.
References solidc_crc32_hash().
Referenced by solidc_crc32_hash().
| uint32_t solidc_djb2_hash | ( | const void * | key | ) |
DJB2 hash function for null-terminated strings.
A simple and effective hash function created by Daniel J. Bernstein. Formula: hash = hash * 33 + c
| key | Pointer to null-terminated string |
DJB2 hash function implementation. Simple and effective hash created by Daniel J. Bernstein.
Definition at line 10 of file hash.c.
References solidc_djb2_hash().
Referenced by solidc_djb2_hash().
| uint32_t solidc_djb2a_hash | ( | const void * | key | ) |
DJB2A hash function (XOR variant) for null-terminated strings.
Variant of DJB2 using XOR instead of addition. Formula: hash = hash * 33 ^ c
| key | Pointer to null-terminated string |
DJB2A hash function implementation (XOR variant). Uses XOR instead of addition for mixing.
Definition at line 26 of file hash.c.
References solidc_djb2a_hash().
Referenced by solidc_djb2a_hash().
| uint32_t solidc_elf_hash | ( | const void * | key | ) |
ELF hash function for null-terminated strings.
Hash function used in the ELF (Executable and Linkable Format) object file format.
| key | Pointer to null-terminated string |
ELF hash function implementation. Used in ELF object file format.
Definition at line 74 of file hash.c.
References solidc_elf_hash().
Referenced by solidc_elf_hash().
| uint32_t solidc_fnv1a_hash | ( | const void * | key | ) |
FNV-1a 32-bit hash function for null-terminated strings.
Fowler-Noll-Vo hash with good distribution properties. Uses XOR-then-multiply approach.
| key | Pointer to null-terminated string |
FNV-1a 32-bit hash function implementation. Fowler-Noll-Vo hash with good distribution.
Definition at line 42 of file hash.c.
References solidc_fnv1a_hash().
Referenced by solidc_fnv1a_hash().
| uint64_t solidc_fnv1a_hash64 | ( | const void * | key | ) |
FNV-1a 64-bit hash function for null-terminated strings.
64-bit version of FNV-1a, providing larger hash space. Useful when 32-bit hash collisions are a concern.
| key | Pointer to null-terminated string |
FNV-1a 64-bit hash function implementation. 64-bit version providing larger hash space.
Definition at line 58 of file hash.c.
References solidc_fnv1a_hash64().
Referenced by solidc_fnv1a_hash64().
| uint32_t solidc_murmur_hash | ( | const char * | key, |
| uint32_t | len, | ||
| uint32_t | seed | ||
| ) |
MurmurHash3 32-bit hash function.
Excellent general-purpose hash with good distribution and performance. Widely used in hash tables and bloom filters.
| key | Pointer to data buffer |
| len | Length of data in bytes |
| seed | Seed value for hash initialization (use 0 for default) |
MurmurHash3 32-bit implementation. Excellent general-purpose hash with good distribution.
Definition at line 128 of file hash.c.
References solidc_murmur_hash().
Referenced by solidc_murmur_hash().
| uint32_t solidc_sdbm_hash | ( | const void * | key | ) |
SDBM hash function for null-terminated strings.
Hash function used in the SDBM database library. Formula: hash = c + (hash << 6) + (hash << 16) - hash
| key | Pointer to null-terminated string |
SDBM hash function implementation. Used in SDBM database library.
Definition at line 95 of file hash.c.
References solidc_sdbm_hash().
Referenced by solidc_sdbm_hash().